Python Forum
Continous Speech Recognition
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Continous Speech Recognition
#1
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)

    try:
        text = r.recognize_google(audio, language="en")
        print("You said: {}".format(text))
    except:
        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')
    f.close()
Thanks a lot for your hlep
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Speech Recognition with timestamps DeanAseraf1 2 2,103 May-05-2020, 10:27 AM
Last Post: pyzyx3qwerty
  Python Speech recognition, word by word AceScottie 6 9,846 Apr-12-2020, 09:50 AM
Last Post: vinayakdhage
  Simulation of Text to speech (without using mic) to Voice recognition suported hardwa Helloworld20 2 632 Apr-08-2020, 02:13 AM
Last Post: Helloworld20
  Speech Recognition Ash23733 1 4,031 Dec-12-2018, 10:00 PM
Last Post: nilamo
  [split] Offline audio to text (Speech Recognition) Nishant260190 0 2,439 Sep-02-2018, 12:33 PM
Last Post: Nishant260190
  Speech Recognition rajeev1729 7 4,470 Oct-06-2017, 04:25 PM
Last Post: hardik

Forum Jump:

User Panel Messages

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