0

We're creating code that translates audio from YouTube in live. I want to send the audio I'm listening to on my computer through the microphone. What should I do?

import speech_recognition
import pyaudio
import speech_recognition as sr
from speech_recognition import *
import os
import googletrans

translator = googletrans.Translator()

r = Recognizer()
m = Microphone()

voice_data = 0

while 1 == True:
    with m as source:                           #음성인식
        audio = r.listen(source)
        try:
            Text = r.recognize_google(audio, language='en')
            result = translator.translate(Text, dest='ko')
            print(result.text)
        except:
            print("can't recognitize")
  • Does this answer your question? [Playing mp3 file through microphone with python](https://stackoverflow.com/questions/37055745/playing-mp3-file-through-microphone-with-python) – Mahrkeenerh Oct 06 '21 at 09:20
  • I want to recognize the voice of the YouTube video that is playing, not the mp3 file. – SilverPage Oct 06 '21 at 09:31
  • it's the same principle, just different input. The re-routing should be the same after you get your audio input. – Mahrkeenerh Oct 06 '21 at 09:32
  • Can I translate videos into 'live' in that way? – SilverPage Oct 06 '21 at 09:35
  • what 'live' do you have in mind? – Mahrkeenerh Oct 06 '21 at 09:38
  • For example, you want to create a code that translates YouTube broadcasts(live stream) in live. (Did I understand your comment properly?) – SilverPage Oct 06 '21 at 09:42
  • do you need it done with python? There already are programs that do the task you are after: https://superuser.com/questions/603294/is-there-a-program-that-allows-me-to-send-audio-output-to-a-microphone-input-ei – Mahrkeenerh Oct 06 '21 at 09:52

0 Answers0