文本转语音-微软Azure-一步一步教你从注册到使用

牙叔教程 简单易懂

为什么不用腾讯阿里讯飞的呢?

他们的中文也许还行, 但是英文我试了都不满意, 我再网上搜到的我认为最好的是

但是丫真贵 Best Free Text To Speech Voice Reader | Speechify

现在的汇率是

139 × 6.91 = 960.49

一年一千块, 好像还行哈, 但是没卡呀, 擦,

比来比去, 还是微软Azure性价比最高,

没有微软Azure的可以去某宝搜索Azure, 一般人也没卡, 你懂吧.

进入Azure首页

云计算服务 | Microsoft Azure


点击右上角登录按钮, 会进入这个页面


点击左上角的创建资源


点击AI + 机器学习, 里面的语音

带*号的都是必填的, 资源组没有的话就新建, 定价层我选的free


填完以后点击下一步


一直点击下一步下一步/ 创建


点击转到资源


记住底部的秘钥和终结点, 后期会用到, 点击 转到 Speech Studio


往下翻页, 就能找到 文本转语音了


你可以先试试语音库, 听一听音色, 选择自己喜欢的, 并记住名字

我选择托尼老师


聆听声音右侧有代码


在音色下方是后序步骤

点击 打开快速入门


选择你自己使用的语言

我选的是js


安装依赖

npm install microsoft-cognitiveservices-speech-sdk

复制黏贴代码

let config = require("./config.js");
console.log(config);
(function () {
  var sdk = require("microsoft-cognitiveservices-speech-sdk");
  var readline = require("readline");
  var audioFile = "cool.mp3";
  // This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
  const speechConfig = sdk.SpeechConfig.fromSubscription(config.SPEECH_KEY, config.SPEECH_REGION);
  const audioConfig = sdk.AudioConfig.fromAudioFileOutput(audioFile);

  // The language of the voice that speaks.
  speechConfig.speechSynthesisVoiceName = "en-US-TonyNeural";

  // Create the speech synthesizer.
  var synthesizer = new sdk.SpeechSynthesizer(speechConfig, audioConfig);

  var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
  });

  rl.question("Enter some text that you want to speak >\n> ", function (text) {
    rl.close();
    // Start the synthesizer and wait for a result.
    synthesizer.speakTextAsync(
      text,
      function (result) {
        if (result.reason === sdk.ResultReason.SynthesizingAudioCompleted) {
          console.log("synthesis finished.");
        } else {
          console.error("Speech synthesis canceled, " + result.errorDetails + "\nDid you set the speech resource key and region values?");
        }
        synthesizer.close();
        synthesizer = null;
      },
      function (err) {
        console.trace("err - " + err);
        synthesizer.close();
        synthesizer = null;
      }
    );
    console.log("Now synthesizing to: " + audioFile);
  });
})();

生成的音频文件叫cool.mp3, 里面就是文字转换好的语音


公众号 牙叔教程

这个ChatGPT星球有多牛逼 (yuque.com)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

牙叔教程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值