Python Forum
speech converstions on live audio stream
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
speech converstions on live audio stream
#1
I want to throw the speech to text conversions on my console when the user has stopped speaking. For it I installed speech_recognition module and python2.

When I run on command line
python -m speech_recognition
it is able to detect the end of the user speech, convert it and print it on my console and returning back to listen the audio from mic until I stop it. I am not sure which converter it is using. The output is accurate enough

Output:
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map Cannot connect to server socket err = No such file or directory Cannot connect to server request channel jack server is not running or cannot be started JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock A moment of silence, please... Set minimum energy threshold to 1806.92166802 Say something! Got it! Now to recognize it... I am testing this speech converters. I am done ! Say something! Got it! Now to recognize it... The second tw test going on.
Now I am trying to do speech recognition through controlled way, using the code snippets examples given and I have choosen microsoft bing for converstions.

def convert_speech_to_text(audio):
	
	message = sr.Recognizer().recognize_bing(audio, key=BING_KEY)
	return(message)

while True:
    # try: 
	with sr.Microphone() as source:
		sr.Recognizer().adjust_for_ambient_noise(source)
		print(1,'say')
		audio = sr.Recognizer().listen(source)
		
	print("Converting")
	message = convert_speech_to_text(audio)
	print(message)
    # except: 
       # print("error")
my program works fine with out while loop, but when using it, it is stuck by printing (1,'say') and it is continuosly listening to the mic and not converting.

Is there any way I can reproduce the command
python -m speech_recognition
does as .py file?
Reply
#2
probably you can try

with sr.Microphone() as source:
    sr.Recognizer().adjust_for_ambient_noise(source)
    print(1,'say')
    while True:
        audio = sr.Recognizer().listen(source)
        print("Converting")
        message = convert_speech_to_text(audio)
        print(message)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Microphone stream manipulation Talking2442 1 2,719 Nov-19-2023, 02:08 PM
Last Post: palumanic
  EEG stream data with mne and brainfolw PaulC 0 488 Aug-22-2023, 03:17 AM
Last Post: PaulC
  Speech Recognition with timestamps DeanAseraf1 3 6,573 Jun-27-2021, 06:58 PM
Last Post: gh_ad
  Decoding a serial stream AKGentile1963 7 8,522 Mar-20-2021, 08:07 PM
Last Post: deanhystad
  Continous Speech Recognition dell91 0 1,828 Oct-29-2020, 10:51 AM
Last Post: dell91
  How to Split Output Audio on Text to Speech Code Base12 2 6,859 Aug-29-2020, 03:23 AM
Last Post: Base12
  Best Video Quality And Stream Harshil 2 2,234 Aug-19-2020, 09:03 AM
Last Post: Harshil
  text to speech Heyjoe 11 6,793 Jul-02-2020, 01:32 AM
Last Post: Heyjoe
  Googles Text to speech justindiaz7474 0 1,656 May-06-2020, 02:04 AM
Last Post: justindiaz7474
  Python Speech Engines? Robo_Pi 2 2,090 Mar-12-2020, 02:46 PM
Last Post: Robo_Pi

Forum Jump:

User Panel Messages

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