#๐ Need help with speech recognition
134 messages ยท Page 1 of 1 (latest)
@faint finch
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
:incoming_envelope: :ok_hand: applied timeout to @faint finch until <t:1733300573:f> (10 minutes) (reason: emoji spam - sent 24 emojis).
The <@&831776746206265384> have been alerted for review.
Shouldn't it be recognize_google_cloud
!unmute 973206297329688647
:incoming_envelope: :ok_hand: pardoned infraction timeout for @faint finch.
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
thanks didn't knew
np
You're on linux?
Okay, after some googling, it seems you need to run sudo nano /usr/share/alsa/alsa.conf and comment out cards.pcm.{device} where {device} is the unknown devices listed
look at the ones in the error message
cards.pcm.rear
cards.pcm.center_lfe
cards.pcm.side
run the code again
wait
what
aplay -l
Which audio device do you use?
Actually, you should just be able to, in that same file, change defaults.ctl.card to 1, and defaults.pcm.card also to 1
done
try again
that seems significantly worse
yeah
change it back
already done
try using .recognize() instead of .recongize_google()
run jack_control start in a terminal?
there is no jack_control
i am copying things down from a google search here, try speaker-test -c2 -Dplughw:3
speaker-test 1.2.8
Playback device is plughw:3
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 3
Playback open error: -2,No such file or directory
pip3 install sounddevice and then in your code import sounddevice
also, what microphone are you using?
which microphone, if you are to device i am using my laptop built in microphone and specificly:
card 1: sofhdadsp [sof-hda-dsp], device 0: HDA Analog (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sofhdadsp [sof-hda-dsp], device 1: HDA Digital (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sofhdadsp [sof-hda-dsp], device 3: HDMI1 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sofhdadsp [sof-hda-dsp], device 4: HDMI2 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sofhdadsp [sof-hda-dsp], device 5: HDMI3 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
did this work?
just import it, apparently that helps
no there is no error but nothing its recording nothing
is your input device set as your laptop mic?
yeah then how i can test my mic online i can even listen my voice outside the code but there its not working
this is my mic which is working
but i noticed a problem when i use like any voice
there are two one is this and anothere one is with headset but that doesn't work and interesting thing is when i use google mic it use with headset one
i have to set it to this one
then only it worked
can you print pyaudio.get_device_count()
did you import pyaudio?
print(pyaudio.PyAudio().get_device_count())
Traceback (most recent call last):
File "/home/pradeep/Code/Project/Iris/core/test.py", line 2, in <module>
print(pyaudio.get_device_count())
of this
import speech_recognition as sr
for mic in sr.Microphone.list_microphone_names():
print(mic)```
replace Microphone() with Microphone(15)
okay
Listening...
python3: malloc.c:4302: _int_malloc: Assertion `(unsigned long) (size) >= (unsigned long) (nb)' failed.
How much RAM do you have?
16
do i need to use it on this or what microphone one
this one or with my speech code
Your speech code
okay then this the error
can you run htop
now run the code again, see what happens
nope no error no recording
did you watch htop?
Run whichever gave you this error
okay
The error apparently means there's some misallocated memory, or just not enough
hmm thats strange everything is fine
import speech_recognition as sr
def listen():
"""Recognizes speech and converts it to text."""
recognizer = sr.Recognizer()
with sr.Microphone() as source:
print("Listening... Speak now.")
try:
# Listen with a pause of 3 seconds after silence
audio = recognizer.listen(source, timeout=10, phrase_time_limit=3)
print("Processing...")
# Return the recognized text
return recognizer.recognize_whisper(audio)
except sr.UnknownValueError:
return "Sorry, I couldn't understand that."
except sr.RequestError:
return "Sorry, there seems to be a problem with the recognition service."
except sr.WaitTimeoutError:
return "No speech detected within the time limit."
def main():
"""Main loop for the voice system."""
print("Voice System Active. Speak to see the transcript. Say 'exit' to stop.")
while True:
transcript = listen().lower()
if "exit" in transcript:
print("Goodbye!")
break
print(f"Transcript: {transcript}")
if __name__ == "__main__":
main()
``` Here's some code I ran on my machine that I know works, try it, see what happens
make sure you run pip install SpeechRecognition[whisper-local]
whats the error now?
same this one
and if you change sr.Microphone() to sr.Microphone(15) what happens
malloc(): mismatching next->prev_size (unsorted)
What about sr.Microphone(0)
Well good news I think I found the problem
It seems python can't access my mic directly
I had to adjust it
There are warning but there is also response
Thank you very much for the support
It's catching some audio but due network problem it couldn't access the Google api
You're welcome
see this https://paste.pythondiscord.com/NB5A
Yay!
Alright, well have a good morning / evening / afternoon
you too
that was a hell lot of brain storming
finnaly it end
what should i do with this post should i just let it be
I believe you do .close
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
๐ Need help with speech recognition