python-scripts/scripts/Speech_To_Text/script.py
2022-10-09 17:33:45 +05:30

16 lines
386 B
Python

import speech_recognition as sr
import os
filename = "sample.wav"
# initialize the recognizer
recognizer = sr.Recognizer()
# open the file
with sr.AudioFile(filename) as source:
# listen for the data (load audio to memory)
audio_data = recognizer.record(source)
# recognize (convert from speech to text)
text = recognizer.recognize_google(audio_data)
print(text)