Skip to content

Instantly share code, notes, and snippets.

@khacanh
Last active August 29, 2015 14:06
Show Gist options
  • Save khacanh/be4b2606d3641fac99a1 to your computer and use it in GitHub Desktop.
Save khacanh/be4b2606d3641fac99a1 to your computer and use it in GitHub Desktop.
speech-to-text
### AT&T
Use this console https://apigee.com/att/embed/console/ATT?req=%7B%22resource%22%3A%22speechtotext%22%2C%22params%22%3A%7B%22query%22%3A%7B%7D%2C%22template%22%3A%7B%7D%2C%22headers%22%3A%7B%22X-SpeechContext%22%3A%22Generic%22%2C%22Content-Language%22%3A%22en-US%22%2C%22Content-Type%22%3A%22audio%2Famr%22%2C%22Accept%22%3A%22application%2Fjson%22%2C%22headers_name_0%22%3A%22Authorization%22%2C%22headers_value_0%22%3A%22Bearer%204rILx5ztnvpRzRBxFVLbl2UsIJBSntlR%22%7D%2C%22body%22%3A%7B%22undefined%22%3A%22%5Cu0001%5Cu0001%22%2C%22attachmentParamName%22%3A%22speech%22%2C%22attachment%22%3A%22C%3A%5C%5Cfakepath%5C%5Cout.amr%22%2C%22attachmentFormat%22%3A%22binary%22%2C%22attachmentContentDisposition%22%3A%22attachment%22%7D%7D%2C%22verb%22%3A%22post%22%7D
docs http://developer.att.com/apis/speech/docs
android guide file:///Users/anhnguyen/Downloads/ATT%20Speech%20SDK%20Developer%20Guide%20for%20Android.pdf
curl "https://api.att.com/oauth/v4/token" \
--insecure \
--header "Accept: application/json" \
--header "Content-Type: application/x-www-form-urlencoded" \
--data "client_id={{id}}&client_secret={{secret}}&grant_type=client_credentials&scope=SPEECH"
### 1. Install pocketsphinx
```
brew install pocketsphinx
```
### 2. Prepare a wav file
```
brew install ffmpeg
ffmpeg -i ~/Desktop/HowLongAreYouGoingToStayInCalifornia.mp3 -acodec pcm_s16le -ac 1 -ar 16000 ~/Desktop/HowLongAreYouGoingToStayInCalifornia.wav
# check output file info
sox --i ~/Desktop/HowLongAreYouGoingToStayInCalifornia.wav
# convert wav file to raw file
sox ~/Desktop/HowLongAreYouGoingToStayInCalifornia.wav ~/Desktop/HowLongAreYouGoingToStayInCalifornia.raw
```
### 3. Run pocketsphinx_continuous
```
pocketsphinx_continuous -infile ~/Desktop/HowLongAreYouGoingToStayInCalifornia.wav
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment