GTTS
v0.0.8
使用Google AI(Gemini)将书面内容转换为语音,以进行文本生成和基于Internet的信息检索。
该项目基于test/app.ts中的示例。它执行以下步骤:
该项目已在Linux(Ubuntu 24.04 LTS X86_64)上进行了测试。 Windows用户可以通过SourceForge安装Sox。 MacOS特定的信息当前不可用。
| 任务 | 优先事项 | 地位 |
|---|---|---|
| 实施双子座聊天 | 高的 | ✅完成 |
| 发展语音识别 | 高的 | ✅完成 |
| 实施音频语言检测 | 高的 | ✅完成 |
| 实施文本语言检测 | 中等的 | ✅完成 |
| 实施音频播放器 | 低的 | ✅完成 |
| 定义枚举 | 低的 | ✅完成 |
| 集成调试 | 低的 | ✅完成 |
在使用此存储库之前,请确保您的系统上安装以下依赖关系:
sudo apt-get install soxsudo apt-get install libsox-fmt-allsudo apt install ffmpeg choco install ffmpeg (使用巧克力)或从官方网站下载目前尚不可用MACOS特定的安装说明。
要安装软件包,请根据您首选的软件包管理器使用以下命令之一:
# npm
$ npm install git+https://github.com/Stawa/GTTS.git --legacy-peer-deps
# Bun
$ bun install git+https://github.com/Stawa/GTTS.git --trust在研究示例之前,请确保您拥有以下API键和凭据:
lib.GoogleGemini )lib.TextToSpeech )lib.VoiceRecognition.fetchTranscriptGoogle )lib.VoiceRecognition.fetchTranscriptDeepgram )lib.SummarizeText )确保将这些API键安全地存储,并且永远不要将其投入版本控制。考虑使用环境变量或安全的密钥管理系统。
这是一个简洁的示例,演示了如何使用Google Gemini API生成响应:
import { GoogleGemini } from "@stawa/gtts" ;
import dotenv from "dotenv" ;
dotenv . config ( ) ;
const gemini = new GoogleGemini ( {
apiKey : process . env . GEMINI_API_KEY ,
model : "gemini-1.5-flash" ,
enableLogging : true ,
} ) ;
async function main ( ) {
try {
const question = "When was Facebook launched?" ;
console . log ( `Question: ${ question } ` ) ;
const response = await gemini . chat ( question ) ;
console . log ( `Gemini's response: ${ response } ` ) ;
} catch ( error ) {
console . error ( "An error occurred:" , error ) ;
}
}
main ( ) ;我们感谢所有合作者的贡献。每个人的努力有助于使这个项目更好。特别感谢我们所有帮助塑造该项目的贡献者!