Skip to content

Commit

Permalink
added catch in code examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlb committed Jun 12, 2018
1 parent 894af0e commit c768ff3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h1>Prompt User Voice Command Example</h1>
<textarea>spoken.say('What is your favorite ice cream?').then( e =&gt; {
spoken.listen().then(
transcript =&gt; alert("Answer: " + transcript)
)
).catch( e =&gt; console.warn(e.message) )
} )</textarea>
<button>Run</button>
</div>
Expand All @@ -47,7 +47,9 @@ <h1>Capture Partial Transcripts</h1>
<p>Capture live "real-time" transcription as you speak.</p>
<div class="codebox">
<textarea>spoken.listen.on.partial( ts =&gt; console.log(ts) )
spoken.listen().then( ts =&gt; console.log("Partial: " + ts) )
spoken.listen()
.then( ts =&gt; console.log("Partial: " + ts) )
.catch( e =&gt; console.warn(e.message) )
</textarea>
<button>Run</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spoken",
"version": "1.0.24",
"version": "1.0.25",
"license": "MIT",
"author": "Stephen Blum",
"description": "JavaScript Web API for Text-to-Speech and Speech-to-Text.",
Expand Down
14 changes: 9 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ which can be used to send over to a chatbot API.
console.log(await spoken.listen());

// or Promise style
spoken.listen().then( transcript => console.log(transcript) );
spoken.listen()
.then( transcript => console.log(transcript) )
.catch( error => console.warn(error.message) )
```

There can only be one concurrent listener.
Expand All @@ -151,15 +153,17 @@ You can catch for this.
// We can only have one concurrent listener.
// So you can catch if there is an error.
spoken.listen()
.then( transcript => console.log(transcript) )
.catch( error => console.error(error) );
.then( transcript => console.log(transcript) )
.catch( error => console.warn(error.message) )
```

Capture live "real-time" transcription as you speak.

```javascript
spoken.listen.on.partial( ts => console.log(ts) );
spoken.listen().then( ts => console.log("Partial: " + ts) );
spoken.listen.on.partial( ts => console.log(ts) );
spoken.listen()
.then( ts => console.log("Partial: " + ts) )
.catch( error => console.warn(error.message) )
```

Additional voice transcription events.
Expand Down

0 comments on commit c768ff3

Please sign in to comment.