forked from Mrinank-Bhowmick/python-beginner-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
23 lines (18 loc) · 647 Bytes
/
main.py
File metadata and controls
23 lines (18 loc) · 647 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import speech_recognition as sr
# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening")
audio = r.listen(source)
# write audio to a RAW file
with open("microphone-results.raw", "wb") as file:
file.write(audio.get_raw_data())
# write audio to a WAV file
with open("microphone-results.wav", "wb") as file:
file.write(audio.get_wav_data())
# write audio to an AIFF file
with open("microphone-results.aiff", "wb") as file:
file.write(audio.get_aiff_data())
# write audio to a FLAC file
with open("microphone-results.flac", "wb") as file:
file.write(audio.get_flac_data())