mirror of
https://github.com/SrIzan10/asuka.git
synced 2026-06-06 00:46:50 +00:00
feat: first commit (it kinda works)
This commit is contained in:
21
python/stt.py
Normal file
21
python/stt.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import speech_recognition as sr
|
||||
import os
|
||||
|
||||
os.environ['PYALSA_DEBUG'] = '0'
|
||||
|
||||
# Initialize recognizer
|
||||
r = sr.Recognizer()
|
||||
|
||||
# Use the default microphone as the audio source
|
||||
with sr.Microphone() as source:
|
||||
print("Speak something...")
|
||||
audio = r.listen(source, phrase_time_limit = 2)
|
||||
|
||||
try:
|
||||
# Use Google Speech Recognition to transcribe the audio
|
||||
text = r.recognize_google(audio)
|
||||
print(text)
|
||||
except sr.UnknownValueError:
|
||||
print("SpeechToTextError")
|
||||
except sr.RequestError:
|
||||
print("SpeechToTextError")
|
||||
Reference in New Issue
Block a user