`NgpTalkify` is an Angular library that provides speech recognition, text-to-speech functionality, and persistent settings management. It offers an intuitive UI component and service utilities for seamless integration with your Angular applications.
npm install ngp-talkify
NgpTalkify is an Angular library that provides speech recognition, text-to-speech functionality, and persistent settings management. It offers an intuitive UI component and service utilities for seamless integration with your Angular applications.
bash
npm install ngp-talkify
`
---
Usage
$3
In your Angular application, import the NgpTalkifyModule in the desired module:
`typescript
import { NgpTalkifyModule } from 'ngp-talkify';
@NgModule({
declarations: [...],
imports: [
NgpTalkifyModule,
...
],
})
export class AppModule {}
`
$3
Include the NgpTalkifyComponent in your template:
`html
`
Handle the textProcessed event in your component:
`typescript
onTextProcessed(text: string | null): void {
console.log('Processed Text:', text);
}
`
$3
Inject NgpTalkifyService to utilize its functionalities:
`typescript
import { NgpTalkifyService } from 'ngp-talkify';
constructor(private ngpTalkifyService: NgpTalkifyService) {}
ngOnInit() {
this.ngpTalkifyService.getLanguages().subscribe(languages => {
console.log('Available Languages:', languages);
});
}
`
---
API Documentation
$3
- Inputs: None.
- Outputs:
- textProcessed: Emits processed text when recognition is complete.
- Methods:
- toggleRecognition(): Starts or stops speech recognition.
- speakText(): Converts input text to speech.
- togglePopup(): Shows or hides additional settings.
- processText(): Processes the current input text.
---
$3
- Methods:
- startRecognition(callback: (text: string) => void): Start speech recognition.
- stopRecognition(): Stop speech recognition.
- getLanguages(): Fetch supported languages for speech recognition.
- getSpeechSettings(type: string): Fetch pitch, rate, and volume settings.
- speakText(text: string): Speak the provided text.
- loadSettings(): Load user settings from storage.
---
$3
- Methods:
- setLocalStorage(key: string, value: ISettings | null): Save settings to Local Storage.
- getLocalStorage(key: string): Retrieve settings from Local Storage.
- setCookie(key: string, value: ISettings | null, expirationDays: number): Save settings in Cookies.
- getCookie(key: string): Retrieve settings from Cookies.
---
Interfaces
$3
- speechRecognitionLanguage: string: Selected recognition language.
- speechSynthesisLanguage: string: Selected synthesis language.
- speechSynthesisPitch: number: Pitch for speech synthesis.
- speechSynthesisRate: number: Rate for speech synthesis.
- speechSynthesisVolume: number: Volume for speech synthesis.
$3
- key: string: Setting key.
- value: number: Setting value.
---
Example
Here's a basic usage example:
`typescript
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template:
,
})
export class AppComponent {
onTextProcessed(text: string | null): void {
console.log('User Input:', text);
}
}
``