You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
529 B
Python
21 lines
529 B
Python
7 years ago
|
#!/usr/bin/env python3
|
||
|
# https://github.com/Uberi/speech_recognition/blob/master/examples/write_audio.py
|
||
|
# NOTE: this example requires PyAudio because it uses the Microphone class
|
||
|
|
||
|
import speech_recognition as sr
|
||
|
import sys
|
||
|
from time import sleep
|
||
|
|
||
|
a1 = sys.argv[1]
|
||
|
|
||
|
# obtain audio from the microphone
|
||
|
r = sr.Recognizer()
|
||
|
with sr.Microphone() as source:
|
||
|
# print("Read every new sentence out loud!")
|
||
|
audio = r.listen(source)
|
||
|
|
||
|
# sleep (1)
|
||
|
|
||
|
# write audio to a WAV file
|
||
|
with open(a1, "wb") as f:
|
||
|
f.write(audio.get_wav_data())
|