import speech_recognition as sr for index, name in enumerate(sr.Microphone.list_microphone_names()): print("Microphone with name \"{1}\" found for `Microphone(device_index={0})`".format(index, name)) |
import speech_recognition as sr r = sr.Recognizer() r.dynamic_energy_threshold = False loopFlag = 1 while loopFlag == 1: with sr.Microphone(device_index=0) as source: print('録音中: ') audio = r.listen(source) try: print('OK!') text = r.recognize_google(audio, language='ja-JP') print(text) if 'ストップ' in text: loopFlag = 0 except: print("録音されていません") |