Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 1x 5x 1x 1x 1x 1x 1x 1x 2x 1x 1x 1x | import { Injectable } from '@angular/core'; import { SpeechProvider, WebSpeechProvider } from './speech-providers'; import { TranslateService } from '@ngx-translate/core'; import { translateLanguages, Language, VoiceCommand } from './utils'; @Injectable({ providedIn: 'root' }) export class SpeechProcessingService { private speechProvider: SpeechProvider; constructor(translate: TranslateService) { this.speechProvider = new WebSpeechProvider(translateLanguages[translate.currentLang]); } /** * Check whether speech recognition is supported by the browser being used by tha application. * * @returns A boolean indicating if speech recognition is supported. */ speechRecognitionSupported() { return this.speechProvider.speechRecognitionSupported(); } /** * Set the speech service's language for speech synthesis and recognition. * * @param language The language to use for the service. */ setLanguage(language: Language) { this.speechProvider.language = language; } /** * Use speech synthesis to say some text. * * @param text The text to say. */ say(text: string) { this.speechProvider.say(text); } /** * Add a voice command to respond to to the service. * * @param voiceCommand The VoiceCommand to recognise and respond to. */ addCommand(voiceCommand: VoiceCommand) { this.speechProvider.addCommand(voiceCommand); } /** * Remove all voice commands from the service. */ removeAllCommands() { this.speechProvider.removeAllCommands(); } } |