Python Forum
Continous Speech Recognition
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Continous Speech Recognition
Hi all,

I am new to this forum and also a bit new to Python to be honest.

I decided to create a project with Python where a microphone listens to a conversation and while listening it gets translated to an other language. Similar to Google Translate on Mobile.

I managed to get input from microphone using PyAudio and also write whats being said and translated to any language i want using google translate pips. At the moment i am only able to do sentence by sentence.

My problem is how should i tackle a live conversation rather than have to stop to process audio to text. Sort of one person is speaking and while the microphone is capturing data, it is being procesed.

This is my code so far:

import speech_recognition as sr
import io
from googletrans import Translator

# print(sr.Microphone.list_microphone_names())
r = sr.Recognizer()

while True:
    result = 0
    f = open("subtitles.txt", "a")
    with sr.Microphone() as source:
        print("Speak Now:")
        audio = r.listen(source)

        text = r.recognize_google(audio, language="en")
        print("You said: {}".format(text))
        print('Sorry could not recognize your voice')
        f.write("problem" + '\n')

    translator = Translator()
    result = translator.translate(text, src='en', dest='es')
    f.write(result.text + '\n')
Thanks a lot for your hlep

Possibly Related Threads…
Thread Author Replies Views Last Post
  Speech Recognition with timestamps DeanAseraf1 3 2,738 Jun-27-2021, 06:58 PM
Last Post: gh_ad
  text to speech Heyjoe 11 2,363 Jul-02-2020, 01:32 AM
Last Post: Heyjoe
  Python Speech recognition, word by word AceScottie 6 10,648 Apr-12-2020, 09:50 AM
Last Post: vinayakdhage
  Simulation of Text to speech (without using mic) to Voice recognition suported hardwa Helloworld20 2 847 Apr-08-2020, 02:13 AM
Last Post: Helloworld20
  Speech Recognition Ash23733 1 4,536 Dec-12-2018, 10:00 PM
Last Post: nilamo
  Need Help With Text to Speech App Lethe 0 859 Oct-24-2018, 10:03 PM
Last Post: Lethe
  [split] Offline audio to text (Speech Recognition) Nishant260190 0 2,666 Sep-02-2018, 12:33 PM
Last Post: Nishant260190
  API Google Speech kowalskilinux 0 1,674 Feb-11-2018, 04:47 PM
Last Post: kowalskilinux
  Speech Recognition rajeev1729 7 4,822 Oct-06-2017, 04:25 PM
Last Post: hardik

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020