Skip to content

Commit

Permalink
✨ feat: Add class
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Nov 15, 2023
1 parent 9c41986 commit 07245e3
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 2 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
],
"scripts": {
"build": "father build",
"build:server": "tsc server.ts --declaration",
"ci": "npm run lint && npm run type-check",
"dev": "father dev",
"docs:build": "npm run setup && npm run build && dumi build",
Expand Down
20 changes: 20 additions & 0 deletions src/class/EdgeSpeechTTS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import edgeVoiceList from '@/data/edgeVoiceList';
import voiceName from '@/data/voiceList';
import { fetchEdgeSpeech } from '@/services/fetchEdgeSpeech';
import { getEdgeVoiceOptions, getVoiceLocaleOptions } from '@/utils/getVoiceList';

export class EdgeSpeechTTS {
private locale?: string;
constructor(locale?: string) {
this.locale = locale;
}
get voiceOptions() {
return getEdgeVoiceOptions(this.locale);
}
get localeOptions() {
return getVoiceLocaleOptions();
}
voiceList = edgeVoiceList;
voiceName = voiceName;
fetch = fetchEdgeSpeech;
}
20 changes: 20 additions & 0 deletions src/class/MicorsoftSpeechTTS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import azureVoiceList from '@/data/azureVoiceList';
import voiceName from '@/data/voiceList';
import { fetchMicrosoftSpeech } from '@/services/fetchMicrosoftSpeech';
import { getAzureVoiceOptions, getVoiceLocaleOptions } from '@/utils/getVoiceList';

export class MicorsoftSpeechTTS {
private locale?: string;
constructor(locale?: string) {
this.locale = locale;
}
get voiceOptions() {
return getAzureVoiceOptions(this.locale);
}
get localeOptions() {
return getVoiceLocaleOptions();
}
voiceList = azureVoiceList;
voiceName = voiceName;
fetch = fetchMicrosoftSpeech;
}
5 changes: 5 additions & 0 deletions src/class/OpenaiSTT.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { fetchOpenaiSTT } from '@/services/fetchOpenaiSTT';

export class OpenaiSTT {
fetch = fetchOpenaiSTT;
}
14 changes: 14 additions & 0 deletions src/class/OpenaiTTS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import openaiVoiceList from '@/data/openaiVoiceList';
import { fetchOpenaiTTS } from '@/services/fetchOpenaiTTS';
import { getOpenaiVoiceOptions, getVoiceLocaleOptions } from '@/utils/getVoiceList';

export class OpenaiTTS {
get voiceOptions() {
return getOpenaiVoiceOptions();
}
get localeOptions() {
return getVoiceLocaleOptions();
}
voiceList = openaiVoiceList;
fetch = fetchOpenaiTTS;
}
38 changes: 38 additions & 0 deletions src/class/VoiceList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
getAzureVoiceOptions,
getEdgeVoiceOptions,
getOpenaiVoiceOptions,
getSpeechSynthesVoiceOptions,
getVoiceLocaleOptions,
} from '@/utils/getVoiceList';

export class VoiceList {
private locale?: string;
constructor(locale?: string) {
this.locale = locale;
}

get speechSynthesVoiceOptions() {
return getSpeechSynthesVoiceOptions(this.locale);
}

get azureVoiceOptions() {
return getAzureVoiceOptions(this.locale);
}

get edgeVoiceOptions() {
return getEdgeVoiceOptions(this.locale);
}

get microsoftVoiceOptions() {
return getEdgeVoiceOptions(this.locale);
}

get openaiVoiceOptions() {
return getOpenaiVoiceOptions();
}

get localeOptions() {
return getVoiceLocaleOptions();
}
}
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export { EdgeSpeechTTS } from './class/EdgeSpeechTTS';
export { MicorsoftSpeechTTS } from './class/MicorsoftSpeechTTS';
export { OpenaiSTT } from './class/OpenaiSTT';
export { OpenaiTTS } from './class/OpenaiTTS';
export { VoiceList } from './class/VoiceList';
export { default as azureVoiceList } from './data/azureVoiceList';
export { default as edgeVoiceList } from './data/edgeVoiceList';
export { default as voiceLocale } from './data/locales';
Expand Down
2 changes: 1 addition & 1 deletion src/services/fetchEdgeSpeech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const fetchEdgeSpeech = async (

const response = await (api?.url
? fetch(api.url, { body: JSON.stringify(payload), method: 'POST' })
: await createEdgeSpeechComletion({ payload }));
: createEdgeSpeechComletion({ payload }));

if (!response.ok) {
throw new Error('Network response was not ok');
Expand Down

0 comments on commit 07245e3

Please sign in to comment.