Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
ember-speak
Advanced tools
Add speech-to-text (STT) and text-to-speech (TTS) to your Ember app.
A demo is setup over at https://tsteuwer.github.io/ember-speak/.
Most browsers have pretty decent support for the SpeechSynthesis API. However, there are some things to note in regards to Chrome -- specifically in regards to this and this.
TLDR
Chrome has a bug where speech would stop reading after about 15 seconds or 200-300 characters. I found a way around this by periodically pausing and resuming the speechSynthesis
instance. This makes it read 100% of the text.
However, I also found another bug in Chrome which stops all sound from occuring if you pause the utterance for more than 15 seconds. It basically stops reading aloud the text when you resume. This is also filed in those same tickets above. If you do end up using this addon, you may (eek) want to prevent pausing for Chrome users.
You can also use the isAvailable
computed properties in both SpeechRecorder
and SpeechReader
services.
export default Ember.Controller.extend({
speechReader: Ember.inject.service(),
speechRecorder: Ember.inject.service(),
[...]
init() {
this._super(...arguments);
this.get('model').setProperties({
readingAvailable: this.get('speechReader.isAvailable'),
recordingAvailable: this.get('speechRecorder.isAvailable'),
});
});
Allow the browser to read text to your users using the SpeechSynthesis and SpeechSynthesisUtterance APIs.
export default Ember.Controller.extend({
speechReader: Ember.inject.service(),
// [...]
actions: {
read(text) {
const currentReader = this.get('model.reader');
const speechReader = this.get('speechReader');
// Always destroy the old reader if used. It will remove events attached to the old utterance since it will be removed from the speechSyntehsis queue
if (currentReader) currentReader.destroy();
const reader = speechReader.getNewReader(text);
this.set('model.reader', reader);
reader.play();
},
pause() {
this.get('model.reader').pause();
},
resume() {
this.get('model.reader').resume();
},
}
});
<button {{action 'read' "This is your profile"}}>
Read Profile
</button>
{{#if model.reader.isPlaying}}
Playing... <button {{action "pause"}}>Pause</button>
{{else if model.reader.isPaused}}
Paused... <button {{action "resume"}}>Resume</button>
{{/if}}
Allow the browser transcribe what your users are saying via the SpeechRecognition API.
export default Ember.Controller.extend({
speechRecorder: Ember.inject.service(),
// [...]
actions: {
reset() {
this.get('model').setProperties({
transcript: '',
error: '',
});
},
stop() {
const recorder = this.get('model.recorder');
if (recorder) {
recorder.stop();
}
},
record() {
this.send('stop');
this.send('reset');
const model = this.get('model');
const speechRecorder = this.get('speechRecorder');
const recorder = speechRecorder.getRecorder();
recorder.on('transcribed', (text) => {
model.set('transcript', model.get('transcript') + text);
});
recorder.on('error', (err) => {
model.set('error', err.msg);
});
recorder.start();
model.set('recorder', recorder);
},
}
});
<button {{action 'record'}}>
Start Recording
</button>
{{#if model.recorder.isRecording}}
Recording... <button {{action "stop"}}>Stop</button>
{{/if}}
<hr />
What you've said: {{model.transcript}}
git clone <repository-url>
this repositorycd ember-speak
npm install
bower install
ember serve
npm test
(Runs ember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit https://ember-cli.com/.
FAQs
Add text-to-speech (TTS) or speech-to-text (STT) to your Ember app.
The npm package ember-speak receives a total of 0 weekly downloads. As such, ember-speak popularity was classified as not popular.
We found that ember-speak demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.