Browse Source

sample WAV audio output for each voice included with OpenedAI Speech

master
Rob Colbert 3 months ago
parent
commit
a52bc15da5
  1. BIN
      acosta.wav
  2. BIN
      assets/speech/news-alloy-alt.wav
  3. BIN
      assets/speech/news-alloy.wav
  4. BIN
      assets/speech/news-fable.wav
  5. BIN
      assets/speech/news-nova.wav
  6. BIN
      assets/speech/news-onyx.wav
  7. BIN
      assets/speech/news-shimmer.wav
  8. 1
      assets/speech/speech-script
  9. 1
      package.json
  10. BIN
      robc.wav
  11. 7
      src/app/services/openai.ts
  12. 1
      src/speechgen.ts

BIN
acosta.wav

Binary file not shown.

BIN
assets/speech/news-alloy-alt.wav

Binary file not shown.

BIN
assets/speech/news-alloy.wav

Binary file not shown.

BIN
assets/speech/news-fable.wav

Binary file not shown.

BIN
assets/speech/news-nova.wav

Binary file not shown.

BIN
assets/speech/news-onyx.wav

Binary file not shown.

BIN
assets/speech/news-shimmer.wav

Binary file not shown.

1
assets/speech/speech-script

@ -0,0 +1 @@
Hello. My name is Shimmer. I am one of the voices that ships with Opened AI Speech, and I'm happy to read the news for you today.

1
package.json

@ -9,6 +9,7 @@
"web-dev": "nodemon ./src/newsroom-web.ts", "web-dev": "nodemon ./src/newsroom-web.ts",
"start-worker": "node --import ./register.js --no-warnings ./src/workers/newsroom.ts", "start-worker": "node --import ./register.js --no-warnings ./src/workers/newsroom.ts",
"worker-dev": "nodemon ./src/workers/newsroom.ts", "worker-dev": "nodemon ./src/workers/newsroom.ts",
"speechgen": "node --import ./register.js --no-warnings ./src/speechgen.ts",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"keywords": [ "keywords": [

BIN
robc.wav

Binary file not shown.

7
src/app/services/openai.ts

@ -40,6 +40,7 @@ export class OpenAiService extends DtpService {
}); });
this.homelabClient = new OpenAI({ this.homelabClient = new OpenAI({
baseURL: env.apis.openai.homelab.baseURL, baseURL: env.apis.openai.homelab.baseURL,
apiKey: "unused",
}); });
} }
@ -138,12 +139,14 @@ export class OpenAiService extends DtpService {
async generateSpeech (input: string, model: string, voice: SpeechVoice) : Promise<IGeneratedFile> { async generateSpeech (input: string, model: string, voice: SpeechVoice) : Promise<IGeneratedFile> {
const audioId = new Types.ObjectId(); const audioId = new Types.ObjectId();
const audioFile = path.join(env.root, audioId.toString()); const audioFile = path.join(env.root, `${audioId.toString()}.wav`);
const response = await this.homelabClient.audio.speech.create({ const response = await this.homelabClient.audio.speech.create({
input, input,
model, model,
voice voice,
response_format: "wav",
speed: 1.0,
}); });
if (!response.ok) { if (!response.ok) {
throw new WebError(response.status, `failed to generate speech audio: ${response.statusText}`); throw new WebError(response.status, `failed to generate speech audio: ${response.statusText}`);

1
src/speechgen.ts

@ -39,6 +39,7 @@ class SpeechGenerator extends DtpProcess {
try { try {
console.log("Speech Generator: A command line tool to generate audio"); console.log("Speech Generator: A command line tool to generate audio");
const generator = new SpeechGenerator(); const generator = new SpeechGenerator();
await generator.start();
const model = process.argv[2]; const model = process.argv[2];
assert(model, "Must specify model (tts-1, tts-1-hd)"); assert(model, "Must specify model (tts-1, tts-1-hd)");

Loading…
Cancel
Save