-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📝 docs(tts): Update documentation and examples for TTS
Updates the documentation and examples to reflect changes in the Text-to-Speech (TTS) API, including renaming markdown files, updating locales, and adjusting sample texts and voices to use English language and voices across various TTS services. Adds a Lithuanian locale and voice options, updates comments in code to English, and removes Chinese-specific examples. Also, corrects the MIME type comment in OpenAISTT and cleans up some code comments for clarity. The changes ensure that the TTS API documentation and examples are consistent and up-to-date, with a focus on English language usage. This includes updating file references to remove language-specific extensions, ensuring examples use English texts and voices, and maintaining clarity and consistency in code comments.
- Loading branch information
Showing
26 changed files
with
81 additions
and
99 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 |
---|---|---|
@@ -1,31 +1,33 @@ | ||
import { EdgeSpeechPayload, EdgeSpeechTTS } from '@/core'; | ||
import { Buffer } from 'node:buffer'; | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
|
||
// 由于 nodejs 环境缺少 `WebSocket` 实例,因此我们需要将其 polyfill | ||
import { EdgeSpeechPayload, EdgeSpeechTTS } from '@/core'; | ||
|
||
// WebSocket | ||
// import WebSocket from 'ws'; | ||
// global.WebSocket = WebSocket; | ||
|
||
// 实例化 EdgeSpeechTTS | ||
const tts = new EdgeSpeechTTS({ locale: 'zh-CN' }); | ||
// EdgeSpeechTTS | ||
const tts = new EdgeSpeechTTS({ locale: 'en-US' }); | ||
|
||
// 创建语音合成请求负载 | ||
// Payload | ||
const payload: EdgeSpeechPayload = { | ||
input: '这是一段语音演示', | ||
input: 'This is a speech demonstration', | ||
options: { | ||
voice: 'zh-CN-XiaoxiaoNeural', | ||
voice: 'en-US-GuyNeural', | ||
}, | ||
}; | ||
|
||
const speechFile = path.resolve('./speech.mp3'); | ||
|
||
// 调用 create 方法来合成语音 | ||
// Main | ||
async function main() { | ||
const response = await tts.create(payload); | ||
const mp3Buffer = Buffer.from(await response.arrayBuffer()); | ||
|
||
fs.writeFileSync(speechFile, mp3Buffer); | ||
} | ||
|
||
// eslint-disable-next-line unicorn/prefer-top-level-await | ||
main(); |
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 |
---|---|---|
@@ -1,32 +1,34 @@ | ||
import { Buffer } from 'node:buffer'; | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
|
||
import { MicrosoftSpeechPayload, MicrosoftSpeechTTS } from '@/core'; | ||
import { Buffer } from 'buffer'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
// 由于 nodejs 环境缺少 `WebSocket` 实例,因此我们需要将其 polyfill | ||
// WebSocket | ||
// import WebSocket from 'ws'; | ||
// global.WebSocket = WebSocket; | ||
|
||
// 实例化 EdgeSpeechTTS | ||
const tts = new MicrosoftSpeechTTS({ locale: 'zh-CN' }); | ||
// EdgeSpeechTTS | ||
const tts = new MicrosoftSpeechTTS({ locale: 'en-US' }); | ||
|
||
// 创建语音合成请求负载 | ||
// Payload | ||
const payload: MicrosoftSpeechPayload = { | ||
input: '这是一段语音演示', | ||
input: 'This is a speech demonstration', | ||
options: { | ||
voice: 'yue-CN-XiaoMinNeural', | ||
style: 'embarrassed', | ||
voice: 'en-US-JacobNeural', | ||
}, | ||
}; | ||
|
||
const speechFile = path.resolve('./speech.mp3'); | ||
|
||
// 调用 create 方法来合成语音 | ||
// create Microsoft Speech | ||
async function main() { | ||
const response = await tts.create(payload); | ||
const mp3Buffer = Buffer.from(await response.arrayBuffer()); | ||
|
||
fs.writeFileSync(speechFile, mp3Buffer); | ||
} | ||
|
||
// eslint-disable-next-line unicorn/prefer-top-level-await | ||
main(); |
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
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
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
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 was deleted.
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
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
Oops, something went wrong.