Pyaudio record
Pyaudio record. 79. Follow asked May 1, 2017 at 17:33. wavfile import write. ライブラリのインストール 以下の To record audio data from your sound device into a NumPy array, use sounddevice. wav" p = pyaudio. I am working on ubuntu 18. CHUNK = 1024. from scipy. rec(): duration = 10. stop() sd. listen() -> VOICED - _BEGIN RECORDING_. listen(1) Sep 9, 2014 · PyAudio is able in record in 24-bit, all that you need to do is put an pyaudio. paInt16. In this mode, the stream will behave like an input stream, with the ability to record the outgoing audio stream. Python code to record audio using pyaudio and wave. But with Windows Vista and above, a new API, WASAPI was introduced, which includes the ability to open a stream to an output device in loopback mode. One of Python’s most popular techniques for real-time audio processing is to use the FFT (Fast Fourier Transform) algorithm. 05: # Audio is ahead time. Relevant line, 75: stream = p. What i need is after audio has been recorded i want to be able to record again but play this NumPy array at the same time. open() (2). import May 27, 2020 · 1. channel_nr = 1. that was ok. Feb 15, 2021 · The issue is that the Python file doesn't seem to detect when the Kivy button is released (when its state is changed from 'down' to 'normal'). Sep 11, 2018 · import pyaudio import wave form_1 = pyaudio. bind((HOST, PORT)) server_socket. Then plotdata will be of shape (44100,2), where first column is of channel 1 data and second is channel 2 data. Need to create a virtual microphone. And that's why it is necessary to write the expression RATE / CHUNK * RECORD_SECONDS in order to record the desired amount of seconds. The audio sample is then sent to a server, which then converts the audio data into a . channels=CHANNELS, rate=RATE, input=True, output=True, frames_per_buffer=CHUNK) data = stream. rec(out=recording) # but what happens if # recording is very long # or frames_per_buffer=CHUNK) data = stream. paInt16 CHANNELS = 1 RATE = 44100 RECORD_SECONDS = 40 HOST = '192. data = stream. device = 1, 5. read_file(file)) foo, _ = tf. Cannot retrieve latest commit at this time. wav" # PyAudio 初期化: FORMAT = pyaudio. Jan 29, 2019 · 3. data = np. com/playlist?list=PLv8Cp2NvcY8CoxylKNIYBd9ZVQ1 Apr 26, 2018 · マイクの音を録音してwaveファイルに保存. default. open () (2). Here is an example taken from pyaudio site which takes audio from microphone for 5 seconds duration then stores audio as stream object and plays back immediately . Okay. This fork however introduces an api that gives you the ability to do so through loopback mode. Install it by typing pip install pyaudio into the terminal Numpy: fundamental package for scientific computing in Python. PyAudio provides Python bindings for PortAudio, the cross-platform audio I/O library. tostring() if stop_callback: callback_flag = pyaudio. This means that you can read from it to record sound (as you have done with stream. recording = ? # create numpy. 5. Basically, I would like to modify the script so that it captures both Mic input and System output in the same file. """. samplerate = 44100 # Hertz. History. Point pyaudio to grab that virtual microphone as an input device. Here is my code. io. If you do that, however, the sound would still Apr 8, 2014 · I'm currently using PyAudio to work on a lightweight recording utility that fits a specific need of an application I'm planning. terminate(). You can modify to store stream object for different Jan 21, 2024 · Can't record more than one wave with pyaudio (no default output device) 5 PyAudio Over Network crashes. But when I set the microphone input volume to high, the audio thus recorded using this code has a lot of noise. May 1, 2017 · The sample code from Pyaudio records for a fixed time. On windows you can install pyaudio as python -m pip install pyaudio. I would like to be able to play a sinusoidal sweep and simultaneously record it. PyAudio () (1), which sets up the portaudio system. 5 # seconds myrecording = sd. This stream has a bunch of parameters like no. paInt16, channels=channel_nr, Apr 20, 2022 · 2. 6. 1. 122' # The Aug 7, 2019 · I have some problem using pyaudio. Code. FORMAT = pyaudio. pawp_record_wasapi_loopback. chunk = 2048 # data is broken into chunks (buffers) of audio. rms(data, WIDTH) # new. WAV file but i can't record the audio. Apr 27, 2022 · import pyaudio import wave filename = "recorded. ) once you have your audio converted to a Numpy array, as np. For channels, you’re going to want 2 to get a stereo. RATE = 44100. import datetime. Add the input_device_index={the right input device} argument to the audio. することができます。この記事では、音声の録音に挑戦してみます。また、録音した音声をmatplotlibを使ってグラフに表示してみます。 1. get_device_info_by_index(i)['name']) #stream using as_loopback to get sound from OS stream = p. The team members who worked on this tutorial are: In this course, you'll learn about libraries that can be used for playing and recording sound in Python, such as PyAudio and python-sounddevice. 4. Ilkin Ilkin. zeros(frame_count*max_nr_of_channels). ターミナル上で下記コマンドでも可能。. CHANNELS = 1. wav' # name of . chunk = 1024. Set that virtual microphone as the speaker for zoom. paInt16 # 16 bits per sample. PyAudio() , which sets up the portaudio system. PyGame, PyAudio and PySoundDevice are three of the best currently maintained packages for playing audio from Python, including from Numpy arrays or streaming sources. 00:45 Like the other examples, this will be 44100 samples per second. 11 and have the following dependencies: libportaudiocpp0; portaudio19-dev; libportaudio2-dev; Basically I am running this: Sep 24, 2021 · Play, Record, Process live audio with Numpy September 24, 2021. How to plot pyaudio input I found a way to record the audio for any duration. Currently, it only captures mic input, (which it seems to be PyAudioWPatch. May 20, 2018 · How to record microphone on macos with pyaudio? 1 How to integrate PyAudio and discord. Now it’s time to create that stream object, so say stream and set this PyAudio provides Python bindings for PortAudio v19, the cross-platform audio I/O library. import wave. Now unplug your mic and run the code again. filename = "output. audio_interface = pyaudio. paused = False def record(): self. 05) To use PyAudio, first instantiate PyAudio using pyaudio. Mic will still be on 1. paInt16: CHUNK = 1024 # チャンクサイズ: SAMPLE_RATE = 44100 # サンプリング周波数: N_CHANNEL = 1 # チャンネル数 モノラルは1, ステレオは2: DURATION = 3 # 収録秒数 # PyAudioのオブジェクト生成: PYAUDIO = pyaudio. 2. Sep 23, 2017 · import pyaudio import speech_recognition from time import sleep class Recorder(): sampling_rate = 44100 num_channels = 2 sample_width = 4 # The width of each sample in bytes. rec(int(fs), samplerate=fs, channels=2) Sep 13, 2016 · If you are willing to use NumPy, there is a much simpler way to record a few seconds of audio into a WAV file: Use the sounddevice module to record the audio data and the soundfile module to save it to a WAV file: import sounddevice as sd. Step – 3: Define a stream to record the audio. The common way is to use the built-in audio processing libraries with the python installation. myrecording = sd. import pyaudio import wave import time import multiprocessing as mp import pyaudio import numpy as np import sounddevice as sd fs = 44100 FORMAT = pyaudio. 01:12 Next, create an interface to PortAudio. Having issue with pyaudio and sockets. The problem is 'Ctrl + C' to stop the recording is not working in 'pycharm'. py to play audio from my microphone. For example: begin: listen() -> nothing is being said. This is the code that I used: Dec 11, 2018 · PyAudio: Used to play and record audio on a variety of platforms. paInt16 channels = 1 sample_rate = 44100 record_seconds = 5 p = pyaudio. channels = 2. PyAudio() audio_stream = audio_interface. open (format=FORMAT Nov 11, 2015 · import socket import pyaudio import wave #record CHUNK = 1024 FORMAT = pyaudio. Jan 27, 2019 · A server receives this audio data and plays the audio as it's being received. close() to terminate the stream. write(data, CHUNK) rms = audioop. zip active_case . PyAudio() This sets up a pyaudio. device に設定するか、 play() や Stream() に device引数 として割り当てることで、デバイスの選択が可能. This means that if you record once for four seconds and then record again for four seconds, the second time returns the four seconds of audio after the first four seconds. get_device_count()): print(i, p. rec(int(duration * fs), samplerate=fs, channels=2) Again, for repeated use you can set defaults using sounddevice. Channels and Sample rates using python and pyaudio. Therefore, to record 5 seconds, we have to take 16 000 samples/second * 5 seconds = 80 000 samples. wav file. You'll also see code snippets for playing and recording sound files and arrays, as well as for converting between different sound file formats. To play MP3, however, we first need to convert the MP3 file to WAV format with ffmpeg. paContinue. Using one pyaudio stream for both data reading and writing. The output is written to the output. wav or . Finally, we terminate the portaudio session using pyaudio. As such, I came across a previously asked question and followed the top answer in Detect & Record Audio in Python. PyAudio() # PySimpleGUI Before running the program, start outputting sound from the device`s speaker or headphones so that the program can record that sound. Below is the code: chunk = 1024. duration = 3 # seconds. To record or play audio, open a stream on the desired device with the desired audio parameters using pyaudio. the arecord tool is the one indicated by the tutorial, so it's the best one to use to test your ability to record. stop_stream() to pause recording, and pyaudio. In order to record a 2 second wav file I used PyAudio (with Pyzo) and the following classical code to record a sound and save it : import pyaudio. You can check the ids of your devices like so: How to select a specific input device with PyAudio. pyaudio can be used to store audio as an stream object. write). paInt16 RATE = 44100 RECORD_SECONDS = 2 WAVE_OUTPUT_FILENAME = "tmp. Or alternatively, stream the pyaudio microphone input directly to an mp3 via ffmpeg without populating a list/array with read data. PyAudio() for i in range(0, p. To select channel 1: plotdata = plotdata [:,0] # 0 for ch1 , 1 for ch2 and then: plotdata = plotdata. get_device_info_by_index(ii) wav_output_filename = 'test1. Currently i can record audio and save it as a NumPy array. read(). paInt24 in your formant type. Only if you want use another device, like in my case i need the OS audio you can to use following code: p = pyaudio. open(), and then pass in the filename, and you’ll want to read this as a binary. sample_format = pyaudio. p = pyaudio. 7, pyaudio version 0. paInt16 CHANNELS = 2 RATE = 44100 CHUNK = 1024 audio = pyaudio. import sys. Sounddevice: Playback and recording of sounds from Python. of channels we want, the frequency rate, and the chunk buffer size. x; pyaudio; Share. Stream. Apr 3, 2023 · Until this bug is fixed in PortAudio, I suggest you switch to a different format; for example, if your device supports paUInt8 (unsigned 8-bit, where 128 is "ground" ), you can use that and manually convert the data to paInt8 (signed 8-bit): import pyaudio. reshape (plotdata. What I need is similar to a music effects pedal where you connect a guitar or mic and it adds reverb or echo or distortion, etc. decode_wav(binary, desired_channels=1) return tf. PyAudio () RECORD_SECONDS = 5 stream = audio. wav". Homepage. Replace CARD and DEVICE value in plugin above. Nov 6, 2023 · PyAudio provides Python bindings for PortAudio v19, the cross-platform audio I/O library. Here's the Python code: def on_press(self): self. Aug 2, 2023 · I want to make a PyQT6 app that will record audio for three seconds once a record button has been clicked. Grab data from the stream, parse and feed it into your ML. We use pyaudio. Pythonでは、標準モジュールpyaudioを用いることで簡単に音声デバイス(マイク)の音を録音できます。. g. ndarray of the correct size # (not sure the best way to do this without # knowing the recording duration) with sd. import sounddevice as sd. squeeze(foo, axis=-1) The recording and saving: channels=CHANNELS, What is different is that in the first case (active-ish noise reduction), I append the sound data for each iteration,after noise reduction, whereas in the second case I record for 5 seconds and THEN apply the noise reduction on the whole set of data. Finally, if each iteration takes 1024 samples, the for will have to loop 80 000/1024 times. read(CHUNK) Feb 4, 2021 · a few days ago i tried to install pyaudio in pycharm by pip install pyaudio and i have a problem with visual c++ tool because i used old version of this and somebody told my to instal pipwin (pip install pipwin) and install pyaudio with pipwin (pipwin install pyaudio) . fs = 44100 # Record at 44100 samples per second. print(sd. I'm uploading example wavs to give you a better perspective: normal_case_wavs. PyAudio() stream = p. paInt24, channels=1, rate=44100, input=True, frames_per_buffer=1024) The record() method, when used inside a with block, always moves ahead in the file stream. Example: The way we capture our web camera frames infinitely under a infinite while loop. , libportaudio2 is the actual system library binary, pyaudio uses that under-the-hood, and python-pyaudio is the distro package that includes the pyaudio module. Jun 17, 2019 · Record speakers output with PyAudio. 1kHz sampling rate chunk = 4096 # 2^12 samples for buffer record_secs = 3 # seconds to record dev_index = 2 # device index found by p. However, it saves the file in WAV format, but the API that I am using only reads Jan 16, 2020 · This is the code I'm using to record the audio. card 0: Devices [USB Device 2345:3x55], device 0: USB Audio [USB Audio] Now it’s time to open the sound file, so we’ll call that wf and set that equal to wave. PyAudio is distributed under the MIT License. seconds = 3 # Duration of recording. You can use e. """A simple example of recording from speakers ('What you hear') using the WASAPI loopback device""" from _spinner_helper import Spinner # Spinner is a helper class that is in the same examples Feb 7, 2021 · 1. So, with pyaudio, you can then call PyAudio(). PyAudio() Apr 5, 2022 · Learn how to capture your microphone input in Python with PyAudio. stop_recording() ''' import pyaudio import wave class Recorder(object): '''A recorder class for recording audio to a WAV file. Mar 27, 2014 · You might be able to use a sample rate conversion library if you want 16000 Hz output. else: callback_flag = pyaudio. 今回は、ノートPCにデフォルトで搭載されているマイクの音を5秒間録音し、waveファイルに出力してみました。. any suggestions? To use PyAudio, first instantiate PyAudio using pyaudio. デバイスIDを、 default. 76 lines (63 loc) · 3. Finally, in order to play or record audio, we can use the PyAudio package which can be installed by means of conda install pyaudio. Feb 26, 2021 · I recorded some audio with PyAudio which I want to visualize. Server: server_socket. 04 using python 3. paInt16 CHANNELS = 1 RATE = 44100 RECORD_SECONDS = 5 p = pyaudio. Step -1: Import the required libraries. This algorithm can extract information from the signal Jun 3, 2023 · PyAudio. I have the following code on WSL2 with Ubuntu: import pyaudio,wave. This is the callback (non-blocking) version. youtube. This should get you started: import pyaudio, sr = 16000. I have uploaded my code to github and also have included all the essential parts it here. Aug 24, 2021 · Hi Guys ! We are back with our brand new video ! Requirements to run this code : 1) Python 3. Oct 17, 2017 · 4. Jan 9, 2020 · import pyaudio import wave import numpy as np CHUNK = 1024 FORMAT = pyaudio. seconds = 3. import numpy as np. shape [0],1) . mp3 file. return data, callback_flag. py The issue is that, the averages of the data clusters don't seem to actually correlate to the intensity of the audio input, and it sometimes drops below the threshold and halts recording even when there is significant input (eg, constant music playing). PyAudio. 3. Dec 31, 2018 · pyaudioというライブラリを使うと、音声を録音・再生・保存etc. 0. Okay, have you tested your configuration using arecord specifically? You introduce other potential complications by using a web site to test your microphone. print(rms) # computer audio power. append(data) This code was taken from Stack Overflow. PyAudio() (1), which acquires system resources for PortAudio. Jan 8, 2019 · I am using the following code to record audio in python, it works perfectly. open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, output=True, frames_per_buffer=chunk) print "* recording" for i in range(0, 44100 / chunk * RECORD_SECONDS): data = stream. Then when the processing is done you can use that output_array to write it to . read(CHUNK) stream. PyAudio tutorialwave module Pythonmicrophone recording PythonPython microphonePython voice input=True, frames_per_buffer=CHUNK, input_host_api_specific_stream_info=SPEAKERS, as_loopback = True) #The part I have modified. 168. It records the speaker output, but the output is mixed with the microphone input. Aug 23, 2017 · PyAudio isn't made to record outputs, only inputs. """Use PyAudio to record two channels of audio to timestamped one hour long WAV files. To be able to record both simultaneously, I use multithreading. Sep 3, 2016 · Find out CAPTURE Device (Soundcard used for audio recording) and note down CARD number and DEVICE number. PyAudio not capturing correct audio data. channels = 2. Homepage; API Documentation; PyPi Jul 25, 2019 · My attempt at sound-device approach. For these examples, we will use this common sinewave-generating code in a Numpy array. Run the program as below. 1 4. I have set the input_device_index=4 which is the input device id for my MADIface XT mic. Depending on your operating system you have you will have to set this up differently. few samples and play them back immediately). import pyaudio. wav file until the person has stopped speaking / the signal is no longer there. Currently, I have a program where the client records an audio sample for 3 seconds. With PyAudio, you can easily use Python to play and record audio on a variety of platforms. Each group of ``sample_width`` bytes represents a single audio sample. Apr 7, 2018 · The video counter will become + (1/fps) when showing an image and audio +sec where sec the seconds of audio you are writing to the stream each time. Apr 20, 2017 · Play and record sound using pyaudio simultaneously. InputStream(samplerate=44100, device=mic, channels=1, callback=self. pylibsamplerate (requires Numpy), which has a very simple API to do conversion (simply src_simple(a, 16000/44100. open(format=FORMAT, channels=1, rate=RATE, input=True, output=True, frames_per_buffer=CHUNK_SIZE) PyAudio docs -- Initializing a stream. 3) pyaudioSo, Jan 12, 2021 · I've tried to remove the amount of time to record for, but all that does is record it for only one second and make the first sample of sound loop. 72) any code editor such as vs code, pycharm, etc. RECORD_SECONDS = 5. One thread records video, and a second one the audio. Pause recording with Pyaudio. Sep 5, 2022 · This function records audio from the user selected input device and plots its waveform with matplotlib. stream = p. chunk, like before, will be 1024. And set the sample rate. frombuffer(data, np. **** List of CAPTURE Hardware Devices ****. Tkinter start/stop button for recording 00:18 Now it’s time to set some attributes. ライブラリのインストール 使い方 サンプルプログラム 1. wav file audio Aug 31, 2020 · 1) Change the list of audio channels in above code to: channels = [1,2]. wav" chunk = 1024 FORMAT = pyaudio. PyAudio: A wrapper around PortAudio for cross-platform playback of WAV files. The main features outlined in its documentation are the following: To use PyAudio, first instantiate PyAudio using pyaudio. get_format_from_width(width=2), channels=1, output=True, rate=OUTPUT_SAMPLE_RATE, input_device_index=INDEX_OF_CHOSEN_INPUT_DEVICE, # This is Apr 12, 2021 · You can try to see whether you are using the right input device. Sep 29, 2013 · Have the microphone "listen" for voiced (above a particular threshold) and then start recording to a . May 21, 2009 · import pyaudio import sys chunk = 1024 FORMAT = pyaudio. Dec 1, 2014 · Having looked through the PyAudio Documentation, you've got it all as it should be but what you're forgetting is that stream is a duplex descriptor. paComplete. To use this, set the flag as AUDCLNT_STREAMFLAGS_LOOPBACK. paInt16, which just sets it to 16 bits per sample. read(CHUNK) frames. CHANNELS = 2. audio_filename = "item_audio. py. import soundfile as sf. Jul 29, 2020 · Use Python and PyAudio to play and record audio on your computer as a part of media processing workflow. PyAudio provides Python bindings for PortAudio v19, the cross-platform audio I/O library. In below example both are 0. read(chunk) # check Oct 16, 2022 · Pyaudio 简介. Currently I am trying to use PyAudio to record the audio but nothing seems to be working. Oct 10, 2017 · Some websites say use numpy arrays but I don't know how. Sep 9, 2015 · PyAudio - Synchronizing playback and record. import pyaudio p = pyaudio. / examples. paInt16 CHANNELS = 2 RATE = 44100 RECORD_SECONDS = 5 WAVE_OUTPUT Feb 18, 2022 · 5 Libraries to Record and Stream Audio in Python: PyDub: Manipulation of audio with an simple and easy high level interface. PyAudio from pynput import keyboard import time import pyaudio import wave CHUNK = 8192 FORMAT = pyaudio. LibROSA: Python library for music and audio analysis. chunk = 1 * sr. python-3. default: sd. I need to record audio in PCM file format from raspberry pi whenever it detects a sound (passing certain threshold), and stops when it goes silent. The code is as follows. In this case, each chunk contains 1024 OUTPUT_FILE = "/tmp/record. query_devices()) Run this code and then look at index one. Jan 3, 2013 · My solution uses pyaudio for audio recording, opencv for video recording, and ffmpeg for muxing the two signals. sleep (0. You can then set record_on and playback_on to True or False from another part of your code while the stream is open/running, causing recording and playback to Apr 18, 2020 · PyAudio Module | Record Audios Using PyAudioCheck the complete Machine Learning Playlist : https://www. paInt16 # 16-bit resolution chans = 1 # 1 channel samp_rate = 44100 # 44. chunk = 1024 # Record in chunks of 1024 samples. listen() -> nothing is being said. samplerate = fs sd. Jul 10, 2017 · recfile2. To read audio data from the stream, we are using pyaudio. This sets up a pyaudio. PyAudio is inspired by: Feb 11, 2020 · 実行例. Stream to play or record audio. Then on audio part of the code you can do something like While audiosec-videosec>=0. PyAudio是Python的一个音频处理模块,它可以让我们在Python中使用音频设备,比如录音、播放音频等。PyAudio是基于PortAudio的,所以它可以在多种平台上使用,比如Windows、Linux、Mac等。 安装 Apr 27, 2016 · import sounddevice as sd. Ie. I am working with an ASIO audio interface. callback): while self. PyAudio - Synchronizing playback and record. Am hoping to get suggestions on how to convert the frames list (pyaudio stream reads) to an mp3 directly. /. 0 PyAudio - How mix wave file into a continuous stream Sep 5, 2020 · For example I am using the below example found on the webs to record to a wav file. Also the pyaudio module used was from the fork Apr 11, 2021 · The official PyAudio build isn’t able to record the system output. Depending on your specific need pyaudio is for sure a good way to go. open(format=p. 386 3 3 Aug 29, 2015 · store_audio_2channels. open. import sounddevice as sd sd. Handle your audio input as a numpy array like I did here in the second answer, but instead of just processing the frames and sending the data back to PyAudio, save each frame in a new output_array. Step – 2: Define a pyaudio object. voice recording using pyaudio. To use ffmpeg in Python, we use an interface tool called Pydub, which directly calls our ffmpeg executable and integrates with Pyaudio. 2. import tempfile. python capture. wav Feb 7, 2018 · I have a simple question, while streaming audio signal from audio jack in Python, using pyaudio library how can I keep streaming the audio signal until I choose to "stop" the program. > arecord -l. Records in mono by default. i can play . The sample_format is going to equal pyaudio. audio. Nov 20, 2016 · i am trying to record voice using python. This is my code for the generation of the sweep: Feb 2, 2024 · There are a few ways to create real-time audio processing in Python. fs = 44100 # Sample rate. return in_data, pyaudio. i tried to use the pyaudio module it saved a wav file on my computer but recorded a static voice. To get started with playback and recording audio on Windows, Linux, and MacOS in a Python environment you should consider using the PyAudio library. Pyaudio Recording audio from streaming Python. Y = 100. Register as a new user and use Qiita Aug 23, 2018 · WRT the python interpreter, it will use the pyaudio module installed by the distro package python-pyaudio, but it does not know about or make use of the distro package manager. I am using 'pyaudio' and 'wave' to record and play back audio. open( format = FORMAT And then to start recording from that specific device, you need to open a PyAudio stream: # Open stream with the index of the chosen device you selected from your initial code. 03 KB. Install it by typing pip install numpy into the terminal Code Copy the following Python script to read audio input to wave files: Apr 15, 2021 · Introduction Pyaudio allows us to play and record sounds with Python. open(format=pyaudio. Stream to record audio. import queue. PyAudio() My goal is to record my voice through the laptop mic and simultaneously adding an effect to it, in python. Continuesly streaming audio signal real time infinitely, Python. non-blocking. With PyAudio, you can easily use Python to play and record audio on a variety of platforms, such as GNU/Linux, Microsoft Windows, and Apple macOS. frames = [] self. 6. python -m sounddevice. int16) ). What I'm writing the program to do is play a wav file through the interface, while simultaneously recording the output from the interface. read) and you write to it to play sound (with stream. Currently I am saving the audio frames to a file and then again loading it with tensorflow: return decodeAudio(tf. – Trees. 0. Sep 24, 2018 · 1. paused: sd. vb ue gr vv vw dx oa qq tg my