-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Neko Ayaka <[email protected]>
- Loading branch information
1 parent
be4cbce
commit 8b1338c
Showing
6 changed files
with
139 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,5 +62,8 @@ | |
"vue-tsc": "^2.1.10", | ||
"yauzl": "^3.2.0", | ||
"zod": "^3.23.8" | ||
}, | ||
"dependencies": { | ||
"elevenlabs": "^0.18.1" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ElevenLabsClient } from 'elevenlabs' | ||
|
||
export default defineEventHandler(async (event) => { | ||
const body = await readBody<{ text: string, apiKey: string }>(event) | ||
const client = new ElevenLabsClient({ | ||
apiKey: body.apiKey, | ||
}) | ||
|
||
const res = await client.generate({ | ||
// voice: 'ShanShan', | ||
// Quite good for English | ||
voice: 'Myriam', | ||
// Beatrice is not 'childish' like the others | ||
// voice: 'Beatrice', | ||
text: body.text, | ||
stream: true, | ||
model_id: 'eleven_multilingual_v2', | ||
voice_settings: { | ||
stability: 0.4, | ||
similarity_boost: 0.5, | ||
}, | ||
}) | ||
|
||
// Set headers for streaming | ||
event.node.res.setHeader('Content-Type', 'audio/mpeg') | ||
event.node.res.setHeader('Transfer-Encoding', 'chunked') | ||
|
||
// res is NodeJS.ReadableStream | ||
return sendStream(event, res) | ||
}) |