Seed-TTS的使用

简介:
Seed-TTS,是由字节跳动开发的高质量文本到语音(TTS)模型,Seed-TTS模型能够生成与人类语音几乎没有区别的语音。
并于2024-06-06发布Seed-TTS模型,产品有豆包,可以听到声音目前是最接近真人的。
在这里插入图片描述

免费开通

  • 1.注册火山云账号
  • 2.进入语音技术控制台
  • 创建应用在这里插入图片描述
  • 进入大模型语音界面,查看创建的应用在这里插入图片描述
  • 试用版目前官网说可以使用所有音色,不过经过我的测试目前只能使用4中音色:
    zh_female_shuangkuaisisi_moon_bigtts
    zh_male_wennuanahu_moon_bigtts
    zh_female_wanwanxiaohe_moon_bigtts
    zh_male_jingqiangkanye_moon_bigtts在这里插入图片描述

免费使用

  • 根据官方说明会有2万字的免费额度
  • 代码:app.py
#coding=utf-8

'''
requires Python 3.6 or later
pip install requests
'''
import base64
import json
import uuid
import requests

# 填写平台申请的appid, access_token以及cluster
appid = "申请的appid"
access_token= "申请的access_token"
cluster = "volcano_tts"

# 爽快思思
voice_type = "zh_female_shuangkuaisisi_moon_bigtts"
host = "openspeech.bytedance.com"
api_url = f"https://{host}/api/v1/tts"

header = {"Authorization": f"Bearer;{access_token}"}

request_json = {
    "app": {
        "appid": appid,
        "token": access_token,
        "cluster": cluster
    },
    "user": {
        "uid": "388808087185088"
    },
    "audio": {
        "voice_type": voice_type,
        "encoding": "mp3",
        "speed_ratio": 1.0,
        "volume_ratio": 1.0,
        "pitch_ratio": 1.0,
    },
    "request": {
        "reqid": str(uuid.uuid4()),
        "text": "使用TEC1-12706制冷片时需要注意的是,为了有效运行并避免损坏,必须确保热面(即非制冷面)有足够的散热措施,通常需要配备散热片和风扇。此外,制冷片的工作效率受温差和热阻的影响,因此设计时需考虑这些因素以优化性能。",
        "text_type": "plain",
        "operation": "query",
        "with_frontend": 1,
        "frontend_type": "unitTson"

    }
}

if __name__ == '__main__':
    try:
        resp = requests.post(api_url, json.dumps(request_json), headers=header)
        print(f"resp body: \n{resp.json()}")
        if "data" in resp.json():
            data = resp.json()["data"]
            file_to_save = open("test_submit.mp3", "wb")
            file_to_save.write(base64.b64decode(data))
    except Exception as e:
        e.with_traceback()

  • 执行 python app.py 运行脚本
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值