【问题标题】:Azure Text to Speech - Not writing to MP3 file using Node.jsAzure 文本转语音 - 不使用 Node.js 写入 MP3 文件
【发布时间】:2020-12-28 00:00:05
【问题描述】:

我正在尝试使用 Azure Text to Speech 创建 MP3 文件。节点文件运行,但没有创建或输出任何内容。 Node.js 文档文件和示例不太好

https://github.com/Azure-Samples/Cognitive-Speech-TTS

https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/get-started-text-to-speech?tabs=require%2Cwindowsinstall&pivots=programming-language-javascript

const sdk = require("microsoft-cognitiveservices-speech-sdk");
var subscriptionKey = "809-myazureapikey";
var serviceRegion = "westeurope"; // e.g., "westus"

function synthesizeSpeech() {
const speechConfig = sdk.SpeechConfig.fromSubscription(subscriptionKey, serviceRegion);
const audioConfig = AudioConfig.fromAudioFileOutput("speech.mp3"); 
const synthesizer = new SpeechSynthesizer(speechConfig, audioConfig);F

synthesizer.speakTextAsync(
    "A simple test to write to a file.",
    result => {
        if (result) {
            console.log(JSON.stringify(result));
        }
        synthesizer.close();
    },
    error => {
        console.log(error);
        synthesizer.close();
    });
  };

是否需要声明并使用fs服务写入文件?

这是一个 Bing Speech 示例,与 Azure 服务和示例不同

https://github.com/palmerabollo/bingspeech-api-client/blob/master/examples/index.js

【问题讨论】:

    标签: javascript node.js azure azure-functions


    【解决方案1】:

    这是一个最小的工作项目:azure-text-to-speech

    它与Microsoft documentation 中提供的示例几乎相同。
    我刚刚修改了一些导入以使其运行,还添加了输出格式设置(因为你提到你想要 MP3,默认是 WAV )。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多