网淘吧来吧,欢迎您!

Voice

2026-04-01 新闻来源:网淘吧 围观:13
电脑广告
手机广告

语音技能

语音技能通过使用edge-tts提供增强的文本转语音功能,允许您将文本转换为语音音频,并提供多种播放选项。

功能

  • 使用微软Edge的TTS引擎进行文本转语音
  • 支持多种语音选项和音频设置
  • 直接播放生成的音频
  • 自动清理临时音频文件
  • 与MEDIA系统集成以实现音频播放

安装

在使用此技能之前,您需要安装所需的依赖项:

Voice

pip3 install edge-tts

或使用技能的安装操作:

await skill.execute({ action: 'install' });

使用

直接说话(推荐)

直接说出文本,无需存储到文件:

const result = await skill.execute({
  action: 'speak',  // New improved action
  text: 'Hello, how are you today?'
});
// Audio is played directly and temporary file is cleaned up automatically

生成文件的文本转语音

使用默认设置将文本转换为语音:

const result = await skill.execute({
  action: 'tts',
  text: 'Hello, how are you today?'
});
// Returns a MEDIA link to the audio file

直接播放:

const result = await skill.execute({
  action: 'tts',
  text: 'Hello, how are you today?',
  playImmediately: true  // Plays the audio immediately after generation
});

使用自定义选项:

const result = await skill.execute({
  action: 'tts',
  text: 'This is a sample of voice customization.',
  options: {
    voice: 'zh-CN-XiaoxiaoNeural',
    rate: '+10%',
    volume: '-5%',
    pitch: '+10Hz'
  }
});

播放现有音频文件

播放现有音频文件:

const result = await skill.execute({
  action: 'play',
  filePath: '/path/to/audio/file.mp3'
});

列出可用语音

获取可用语音列表:

const result = await skill.execute({
  action: 'voices'
});

清理临时文件

清理超过1小时(默认)的临时音频文件:

const result = await skill.execute({
  action: 'cleanup'
});

或指定自定义时间阈值:

const result = await skill.execute({
  action: 'cleanup',
  options: {
    hoursOld: 2  // Clean files older than 2 hours
  }
});

选项

文本转语音提供以下选项:

  • 语音:要使用的语音(默认:'zh-CN-XiaoxiaoNeural')
  • 语速:语速调整(默认:'+0%')
  • 音量:音量调整(默认:'+0%')
  • 音调:音调调整(默认:'+0Hz')

支持的语音

Edge-TTS支持多种语言的语音:

  • 中文:zh-CN-XiaoxiaoNeural、zh-CN-YunxiNeural、zh-CN-YunyangNeural
  • 英语(美国):en-US-Standard-C、en-US-Standard-D、en-US-Wavenet-F
  • 英语(英国):en-GB-Standard-A, en-GB-Wavenet-A
  • 日语:ja-JP-NanamiNeural
  • 韩语:ko-KR-SunHiNeural
  • 以及更多...

文件管理

  • 音频文件暂时存储在temp目录
  • 文件在1小时后(默认)自动清理
  • 直接说话选项在5秒后清理文件

要求

  • Python 3.x
  • pip 包管理器
  • edge-tts 库(通过pip3 install edge-tts安装)

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏

文章底部电脑广告
手机广告位-内容正文底部
上一篇:Nanobanana Pro 下一篇:Mia Twitter Stealth

相关文章

您是本站第383672名访客 今日有1篇新文章/评论