mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-27 14:01:12 +00:00
16 lines
386 B
Python
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)
|