8000 GitHub - fxjs/tzfe-tts: 文本转语音服务 · GitHub
[go: up one dir, main page]

Skip to content
  • fxjsPublic

    About

    文本转语音服务

    Resources

    Stars

    11 stars

    Watchers

    1 watching

    Forks

    Repository files navigation

    tzfe-tts

    文本转语音服务(支持跨域、鉴权)

    环境装备

    安装 deno、pnpm

    启动

    pnpm start

    编译

    pnpm compile:linux
    #pnpm compile:macos
    #pnpm compile:windows
    pnpm compile:linux
    # 运行二进制包
    ./tzfe-tts

    参考编译文档

    环境变量

    TTS_PORT 启动端口默认 8901
    
    TTS_AUTH_TOKEN 鉴权token (如设置为TestToken,调用接口时需在headers里添加Authorization字段)
    

    部署(以 Arch、Debian 为例)

    方式1. 安装 tzfe-tts.service 服务,使用 systemctl 进行管理
    curl -fsSL https://github.com/fxjs/tzfe-tts/releases/latest/download/install.sh | sh
    # 查看服务状态
    systemctl status tzfe-tts
    
    # 查看日志
    tail -F /var/log/tzfe-tts/tzfe-tts.log
    方式2. Docker镜像
    • ==

    卸载

    curl -fsSL https://github.com/fxjs/tzfe-tts/releases/latest/download/uninstall.sh | sh

    配置日志轮转(可选)

    curl -fsSL https://github.com/fxjs/tzfe-tts/releases/latest/download/logrotate.sh | sh

    调用

    fetch('http://0.0.0.0:8901/v1/audio/speech', {
      method: 'POST',
      // headers: { 'Content-Type': 'application/json', Authorization: 'Bearer ' + 'TestToken' },
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        model: 'zh-CN-shaanxi-XiaoniNeural',
        input: '网关异常,请及时处理。',
        voice: 'rate:0|pitch:0'
      })
    })
      .then((response) => response.blob())
      .then((blob) => {
        const audioUrl = URL.createObjectURL(blob);
        const audio = new Audio(audioUrl);
        audio.play();
      });

    About

    文本转语音服务

    Resources

    Stars

    11 stars

    Watchers

    1 watching

    Forks

    Releases

    Packages

    Used by

    Contributors

    Languages

    0