@@ -73,9 +73,9 @@ aurora.config.app_token = "YOUR_APP_TOKEN" # put your app token here
7373
7474# open an existing WAV file (16-bit, mono, 16KHz WAV PCM)
7575with open (" test.wav" , " rb" ) as f:
76- a = AudioFile(f.read())
77- p = Speech(a).text()
78- print (p.text) # 'hello world'
76+ a = AudioFile(f.read())
77+ p = Speech(a).text()
78+ print (p.text) # 'hello world'
7979```
8080
8181#### Convert a previous Text API call to Speech
@@ -129,18 +129,18 @@ from auroraapi.speech import continuously_listen
129129
130130# Continuously listen and convert to speech (blocking example)
131131for speech in continuously_listen():
132- p = speech.text()
133- print (p.text)
132+ p = speech.text()
133+ print (p.text)
134134
135135# Reduce the amount of silence in between speech segments
136136for speech in continuously_listen(silence_len = 0.5 ):
137- p = speech.text()
138- print (p.text)
137+ p = speech.text()
138+ print (p.text)
139139
140140# Fixed-length speech segments of 3 seconds
141141for speech in continuously_listen(length = 3.0 ):
142- p = speech.text()
143- print (p.text)
142+ p = speech.text()
143+ print (p.text)
144144```
145145
146146#### Listen and Transcribe
@@ -155,7 +155,7 @@ print("You said: {}".format(text.text))
155155
156156# You can also use this in the same way as `continuously_listen`
157157for text in continuously_listen_and_transcribe(silence_len = 0.5 ):
158- print (" You said: {} " .format(text.text))
158+ print (" You said: {} " .format(text.text))
159159```
160160
161161#### Listen and echo example
@@ -164,7 +164,7 @@ for text in continuously_listen_and_transcribe(silence_len=0.5):
164164from auroraapi.speech import continuously_listen_and_transcribe
165165
166166for text in continuously_listen_and_transcribe():
167- text.speech().audio.play()
167+ text.speech().audio.play()
168168```
169169
170170### Interpret (Language Understanding)
@@ -195,14 +195,14 @@ print(i.entities) # { "location": "los angeles" }
195195from auroraapi.text import Text
196196
197197while True :
198- # Repeatedly ask the user to enter a command
199- user_text = raw_input (" Enter a command:" )
200- if user_text == " quit" :
201- break
202-
203- # Interpret and print the results
204- i = Text(user_text).interpret()
205- print (i.intent, i.entities)
198+ # Repeatedly ask the user to enter a command
199+ user_text = raw_input (" Enter a command:" )
200+ if user_text == " quit" :
201+ break
202+
203+ # Interpret and print the results
204+ i = Text(user_text).interpret()
205+ print (i.intent, i.entities)
206206```
207207
208208#### Smart Lamp
@@ -216,13 +216,11 @@ valid_words = ["light", "lights", "lamp"]
216216valid_entities = lambda d : " object" in d and d[" object" ] in valid_words
217217
218218for speech in continuously_listen(silence_len = 0.5 ):
219- i = speech.text().interpret()
220- if i.intent == " turn_on" and valid_entities(i.entities):
221- # do something to actually turn on the lamp
222- print (" Turning on the lamp" )
223- elif i.intent == " turn_off" and valid_entities(i.entities):
224- # do something to actually turn off the lamp
225- print (" Turning off the lamp" )
219+ i = speech.text().interpret()
220+ if i.intent == " turn_on" and valid_entities(i.entities):
221+ # do something to actually turn on the lamp
222+ print (" Turning on the lamp" )
223+ elif i.intent == " turn_off" and valid_entities(i.entities):
224+ # do something to actually turn off the lamp
225+ print (" Turning off the lamp" )
226226```
227-
228-
0 commit comments