前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >语音识别API - 实现文字转语音

语音识别API - 实现文字转语音

作者头像
小锋学长生活大爆炸
发布2022-03-29 13:45:02
12K0
发布2022-03-29 13:45:02
举报

目录

搜狗(目前好用,免费)

百度(现在收费了,送一定额度)

腾讯(收费的)

搜狗(目前好用,免费)

代码语言:javascript
复制
    def textToAudio_Sougou(message, filePath):
        # https://ai.so    gou.com/doc/?url=/docs/content/tts/references/rest/ 
        '''
        curl -X POST \
             -H "Content-Type: application/json" \
             --data '{
          "appid": "xxx",
          "appkey": "xxx",
          "exp": "3600s"
        }' https://api.zhiyin.sogou.com/apis/auth/v1/create_token
        '''

        token = 'xxx'
        headers = { 
            'Authorization' : 'Bearer '+token,
            'Appid' : 'xxx',
            'Content-Type' : 'application/json',
            'appkey' : 'xxx',
            'secretkey' : 'xxx'
        }
        data = {
          'input': {
            'text': message
          },
          'config': {
            'audio_config': {
              'audio_encoding': 'LINEAR16',
              'pitch': 1.0,
              'volume': 1.0,
              'speaking_rate': 1.0
            },
            'voice_config': {
              'language_code': 'zh-cmn-Hans-CN',
              'speaker': 'female'
            }
          }
        }
        
        result = requests.post(url=url, headers=headers, data=json.dumps(data, ensure_ascii=False).encode('utf-8')).content
        with open(filePath, 'wb') as f:
            f.write(result)

百度(现在收费了,送一定额度)

腾讯(收费的)

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-03-05 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 搜狗(目前好用,免费)
  • 百度(现在收费了,送一定额度)
  • 腾讯(收费的)
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档