style: run format:apply
This commit is contained in:
@@ -1,37 +1,37 @@
|
||||
import { TTSModule, TTSResponse } from "../tts";
|
||||
import { TTSModule, TTSResponse } from '../tts';
|
||||
|
||||
import { VoicesManager, Communicate } from 'edge-tts-universal';
|
||||
|
||||
class AzureTTS implements TTSModule {
|
||||
private voices: Array<string> | undefined = undefined;
|
||||
private voices: Array<string> | undefined = undefined;
|
||||
|
||||
public name: string = "Azure";
|
||||
|
||||
async getVoices(): Promise<Array<string> | undefined> {
|
||||
if (!this.voices) {
|
||||
const voiceMgr = await VoicesManager.create();
|
||||
const voiceQuery = await voiceMgr.find({});
|
||||
public name: string = 'Azure';
|
||||
|
||||
this.voices = voiceQuery.map((voice) => voice.ShortName);
|
||||
}
|
||||
async getVoices(): Promise<Array<string> | undefined> {
|
||||
if (!this.voices) {
|
||||
const voiceMgr = await VoicesManager.create();
|
||||
const voiceQuery = await voiceMgr.find({});
|
||||
|
||||
return this.voices;
|
||||
};
|
||||
this.voices = voiceQuery.map((voice) => voice.ShortName);
|
||||
}
|
||||
|
||||
async generate(voice: string, text: string): Promise<TTSResponse> {
|
||||
const comm = new Communicate(text, {
|
||||
voice: voice
|
||||
});
|
||||
return this.voices;
|
||||
}
|
||||
|
||||
const buffers: Buffer[] = [];
|
||||
for await (const chunk of comm.stream()) {
|
||||
if (chunk.type === 'audio' && chunk.data) {
|
||||
buffers.push(chunk.data);
|
||||
}
|
||||
}
|
||||
async generate(voice: string, text: string): Promise<TTSResponse> {
|
||||
const comm = new Communicate(text, {
|
||||
voice: voice
|
||||
});
|
||||
|
||||
return { data: Buffer.concat(buffers) };
|
||||
};
|
||||
const buffers: Buffer[] = [];
|
||||
for await (const chunk of comm.stream()) {
|
||||
if (chunk.type === 'audio' && chunk.data) {
|
||||
buffers.push(chunk.data);
|
||||
}
|
||||
}
|
||||
|
||||
return { data: Buffer.concat(buffers) };
|
||||
}
|
||||
}
|
||||
|
||||
export default new AzureTTS();
|
||||
|
||||
Reference in New Issue
Block a user