mirror of
https://github.com/FAUSheppy/ths-speech
synced 2025-12-09 04:38:34 +01:00
basic pythong construct
This commit is contained in:
@@ -2,11 +2,11 @@ import speech_recognition as spr
|
||||
def analyse(file_path):
|
||||
''' returns the transcripted audio, or None if the analysis fails '''
|
||||
recognizer = spr.Recognizer()
|
||||
with sr.AudioFile(file_path) as source:
|
||||
audio = r.record(source)
|
||||
with spr.AudioFile(file_path) as source:
|
||||
audio = recognizer.record(source)
|
||||
|
||||
try:
|
||||
string = r.recognize_google(audio)
|
||||
string = recognizer.recognize_google(audio)
|
||||
except spr.UnknownValueError:
|
||||
log.log("Audio file is broken or not an audio file")
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user