Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Code-Sleep-Python/speech-to-text/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Speech-To-Text

Simple Script to get User input from microphone and use Google's API to transform into text.

# Installation

Install python-pyaudio:

```
sudo apt-get install python-pyaudio
```

Install portaudio:

```
sudo apt-get install portaudio19-dev
```

Sadly, the PyAudio is not updated and doesn't work on the latest version of Python3 so:

```
virtualenv -p python2.7 req
source req/bin/activate
pip install PyAudio
pip install SpeechRecognition
```

# Test the app:

```
source req/bin/activate
python stt.py
```

# TODO:

- Find a way to make this work for Python3.

- Add new recognition APIs.
2 changes: 2 additions & 0 deletions Code-Sleep-Python/speech-to-text/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PyAudio==0.2.11
SpeechRecognition==3.8.1
14 changes: 14 additions & 0 deletions Code-Sleep-Python/speech-to-text/stt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import speech_recognition as sr

r = sr.Recognizer()

with sr.Microphone() as source:
print("Say something... ")
audio = r.listen(source)

try:
print("Google thinks you said: {}".format(r.recognize_google(audio)))
except sr.UnkownValueError:
print("Couldn't understand")
except sr.RequestError as e:
print("Couldn't request results; {}".format(e))