#!/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 RAW file # with open("microphone-results.raw", "wb") as f: # f.write(audio.get_raw_data()) # write audio to a WAV file with open(a1, "wb") as f: f.write(audio.get_wav_data())