0

So I'm playing around with the speech recognition python software:

#! /usr/bin/python                                                   
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:                # use the default  microphone as the audio source
    audio = r.listen(source)                   # listen for the first phrase and extract it into audio data

try:
    print("You said " + r.recognize(audio))    # recognize speech using Google Speech Recognition
except LookupError:                            # speech is unintelligible
    print("Could not understand audio")

Now, this works surprisingly well and is extremely fun to fool around with, but unfortunately on some versions of Ubuntu there's an unavoidable and unappealing bluetooth error message that prints about 6 times everytime that r.listen(source) is run.

Is there a way to hide that rubbish output from r.listen(source) and still have my print statements bellow work???

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
driedupsharpie
  • 133
  • 2
  • 10
  • What does the error message look like? It is probably a driver that is writing that to standard error or similar, having the exact error message might help us confirm this. – Martijn Pieters Aug 27 '15 at 21:55
  • Not really familiar with speech recognition but is there any you could do `while audio = your_error_text or not audio: audio = r.listen(source)` – MrAlexBailey Aug 27 '15 at 21:56
  • Do the messages look like `ALSA lib audio/pcm_bluetooth.c:1613:(audioservice_expect) BT_GET_CAPABILITIES failed : Input/output error(5)` perhaps? – Martijn Pieters Aug 27 '15 at 21:59
  • yes actually, the site I was on suggested that the only thing to do was to ignore this – driedupsharpie Aug 27 '15 at 22:23

0 Answers0