File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed 
Code-Sleep-Python/speech-to-text Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ # Speech-To-Text  
2+ 
3+ Simple Script to get User input from microphone and use Google's API to transform into text.
4+ 
5+ # Installation  
6+ 
7+ Install python-pyaudio:
8+ 
9+ ``` 
10+ sudo apt-get install python-pyaudio 
11+ ``` 
12+ 
13+ Install portaudio:
14+ 
15+ ``` 
16+ sudo apt-get install portaudio19-dev 
17+ ``` 
18+ 
19+ Sadly, the PyAudio is not updated and doesn't work on the latest version of Python3 so:
20+ 
21+ ``` 
22+ virtualenv -p python2.7 req 
23+ source req/bin/activate 
24+ pip install PyAudio 
25+ pip install SpeechRecognition 
26+ ``` 
27+ 
28+ # Test the app:  
29+ 
30+ ``` 
31+ source req/bin/activate 
32+ python stt.py 
33+ ``` 
34+ 
35+ # TODO:  
36+ 
37+ -  Find a way to make this work for Python3.
38+ 
39+ -  Add new recognition APIs.
Original file line number Diff line number Diff line change 1+ PyAudio == 0.2.11 
2+ SpeechRecognition == 3.8.1 
Original file line number Diff line number Diff line change 1+ import  speech_recognition  as  sr 
2+ 
3+ r  =  sr .Recognizer ()
4+ 
5+ with  sr .Microphone () as  source :
6+     print ("Say something... " )
7+     audio  =  r .listen (source )
8+ 
9+ try :
10+     print ("Google thinks you said: {}" .format (r .recognize_google (audio )))
11+ except  sr .UnkownValueError :
12+     print ("Couldn't understand" )
13+ except  sr .RequestError  as  e :
14+     print ("Couldn't request results; {}" .format (e ))
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments