mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-30 15:31:10 +00:00
Merge pull request #248 from arpitbhardwaj/speech_to_text
Added speech to text script
This commit is contained in:
commit
98a3661dd7
9
scripts/Speech_To_Text/README.md
Normal file
9
scripts/Speech_To_Text/README.md
Normal 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`
|
1
scripts/Speech_To_Text/requirements.txt
Normal file
1
scripts/Speech_To_Text/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
speech_recognition
|
BIN
scripts/Speech_To_Text/sample.wav
Normal file
BIN
scripts/Speech_To_Text/sample.wav
Normal file
Binary file not shown.
15
scripts/Speech_To_Text/script.py
Normal file
15
scripts/Speech_To_Text/script.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user