Recording the audio we need
Sometimes you may not want the entire audio file you're working with. The duration
and offset
parameters of the record()
method can help with this.
After exploring your dataset, you find there's one file, imported as nothing_at_end
which has 30-seconds of silence at the end and a support call file, imported as out_of_warranty
has 3-seconds of static at the front.
Setting duration
and offset
means the record()
method will record up to duration
audio starting at offset
. They're both measured in seconds.
Diese Übung ist Teil des Kurses
Spoken Language Processing in Python
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Convert AudioFile to AudioData
with nothing_at_end as source:
nothing_at_end_audio = recognizer.record(source,
duration=____,
offset=None)
# Transcribe AudioData to text
text = recognizer.recognize_google(nothing_at_end_audio,
language="en-US")
print(text)