Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
feat(game-detail): basic TTS
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Sep 18, 2020
1 parent eecf041 commit de59145
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/app/game-detail/game-detail.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class GameDetailPage implements OnInit {
public stream: APIStream,
) { }

async ngOnInit() {
ngOnInit() {
/*
this.updateLog = [
{ time: '04:17', entry: 'really really really really long entry that has some excessive amounts of text' },
Expand All @@ -48,10 +48,25 @@ export class GameDetailPage implements OnInit {
time: ('0' + now.getHours()).slice(-2) + ':' + ('0' + now.getMinutes()).slice(-2) + ':' + ('0' + now.getSeconds()).slice(-2),
entry: game.lastUpdate,
});
if (game.lastUpdate.toLowerCase().indexOf('game over') < 0) {
this.read(game.lastUpdate);
}
}
});
}

public read(text: string) {
if (window.speechSynthesis) {
try {
const msg = new SpeechSynthesisUtterance();
msg.text = text;
window.speechSynthesis.speak(msg);
} catch (err) {
// just eat it
}
}
}

public close() {
if (this.subscription) {
this.subscription.unsubscribe();
Expand Down

0 comments on commit de59145

Please sign in to comment.