Added speech to text script

This commit is contained in:
arpitbhardwaj 2022-10-09 17:33:45 +05:30
parent 309a904dd3
commit 2911f6fbe3
4 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,9 @@
# Speech to Text
This is a simple script that lets you convert speech to text
#### Usage
* Clone the repo
* Move to folder "scripts/Speech_To_Text"
* download the python libraries mentioned in requirements.txt using `pip install <library>`
* run `python script.py`

View File

@ -0,0 +1 @@
speech_recognition

Binary file not shown.

View File

@ -0,0 +1,15 @@
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)