Update framework
This commit is contained in:
11
framework/tts/outputs/aria.d.ts
vendored
Normal file
11
framework/tts/outputs/aria.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { BaseOutput } from './base-output';
|
||||
export declare class AriaOutput extends BaseOutput {
|
||||
private container;
|
||||
private speechDisplay;
|
||||
private timeout;
|
||||
constructor(options?: any);
|
||||
private init;
|
||||
speak(text: string): void;
|
||||
stop(): void;
|
||||
clearDisplay(): void;
|
||||
}
|
32
framework/tts/outputs/aria.js
Normal file
32
framework/tts/outputs/aria.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { BaseOutput } from './base-output';
|
||||
export class AriaOutput extends BaseOutput {
|
||||
constructor(options = {}) {
|
||||
super();
|
||||
this.timeout = 100;
|
||||
this.timeout = options.timeout || 100;
|
||||
this.init();
|
||||
}
|
||||
init() {
|
||||
this.container = document.createElement('div');
|
||||
this.container.setAttribute('aria-live', 'polite');
|
||||
this.speechDisplay = document.createElement('div');
|
||||
this.speechDisplay.setAttribute('aria-live', 'polite');
|
||||
this.container.append(this.speechDisplay);
|
||||
document.body.appendChild(this.container);
|
||||
document.body.insertBefore(this.container, document.body.firstChild);
|
||||
}
|
||||
speak(text) {
|
||||
this.clearDisplay();
|
||||
const node = document.createTextNode(text);
|
||||
const para = document.createElement('p');
|
||||
para.appendChild(node);
|
||||
this.speechDisplay.appendChild(para);
|
||||
setTimeout(this.clearDisplay.bind(this), this.timeout);
|
||||
}
|
||||
stop() {
|
||||
this.clearDisplay();
|
||||
}
|
||||
clearDisplay() {
|
||||
this.speechDisplay.innerHTML = '';
|
||||
}
|
||||
}
|
5
framework/tts/outputs/base-output.d.ts
vendored
Normal file
5
framework/tts/outputs/base-output.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare class BaseOutput {
|
||||
speak(text: string): void;
|
||||
stop(): void;
|
||||
setOptions(options: any): void;
|
||||
}
|
11
framework/tts/outputs/base-output.js
Normal file
11
framework/tts/outputs/base-output.js
Normal file
@@ -0,0 +1,11 @@
|
||||
export class BaseOutput {
|
||||
speak(text) {
|
||||
return;
|
||||
}
|
||||
stop() {
|
||||
return;
|
||||
}
|
||||
setOptions(options) {
|
||||
return;
|
||||
}
|
||||
}
|
3
framework/tts/outputs/webtts.d.ts
vendored
Normal file
3
framework/tts/outputs/webtts.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { BaseOutput } from './base-output';
|
||||
export declare class WebTTSOutput extends BaseOutput {
|
||||
}
|
3
framework/tts/outputs/webtts.js
Normal file
3
framework/tts/outputs/webtts.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import { BaseOutput } from './base-output';
|
||||
export class WebTTSOutput extends BaseOutput {
|
||||
}
|
Reference in New Issue
Block a user