【问题标题】:Cannot control volume level with prosody in google Cloud Text-to-Speech无法使用谷歌云文本到语音中的韵律控制音量级别
【发布时间】:2019-09-23 10:05:19
【问题描述】:

SSML Volume 属性对输出音频没有影响

下面是ssml

<speak>
    <prosody volume = "+0dB"> This is a sentence with volume 10 For GOOGLE. </prosody>
    <s><prosody volume = "+6dB"> This is a sentence with volume 6 For GOOGLE. </prosody></s> 
    <s><prosody volume = "+24dB"> This is a sentence with volume +24 For GOOGLE. </prosody></s>
    <s><prosody volume = "+48dB"> This is a sentence with volume +48 For GOOGLE.</prosody></s> <s><prosody volume = "+196dB"> This is a sentence with volume +196 For GOOGLE.</prosody></s>
</speak>

这是一个示例代码

  String ssml = $"<speak><prosody volume = \"+0dB\"> This is a sentence with volume 10 For GOOGLE.</prosody>" +
                $" <s><prosody volume = \"+6dB\"> This is a sentence with volume 6 For GOOGLE.</prosody></s>" +
                $" <s><prosody volume = \"+24dB\"> This is a sentence with volume +24 For GOOGLE.</prosody></s>" +
                $" <s><prosody volume = \"+48dB\"> This is a sentence with volume +48 For GOOGLE.</prosody></s>" +
                $" <s><prosody volume = \"+196dB\"> This is a sentence with volume +196 For GOOGLE.</prosody></s>" +
                $"</speak>";

配音(ssml);

    public static void Dubb(string ssml)
    {
        var client = TextToSpeechClient.Create();

        // The input to be synthesized, can be provided as text or SSML.
        var input = new SynthesisInput
        {
            Ssml = ssml
        };

        // Build the voice request.
        var voiceSelection = new VoiceSelectionParams
        {
            LanguageCode = "en-US",
            SsmlGender = SsmlVoiceGender.Female
        };

        // Specify the type of audio file.
        var audioConfig = new AudioConfig
        {
            AudioEncoding = AudioEncoding.Linear16
        };


        // Perform the text-to-speech request.
        var response = client.SynthesizeSpeech(input, voiceSelection, audioConfig);

        // Write the response to the output file.
        using (var output = File.Create("output.wav"))
        {
            response.AudioContent.WriteTo(output);
        }

    }

我预计每行的音量都会增加,但事实并非如此。

【问题讨论】:

    标签: ssml


    【解决方案1】:

    我试过了

    <speak>
        <prosody volume = "+0dB"> This is a sentence with volume 10 For GOOGLE. </prosody>
        <s><prosody volume = "+6dB"> This is a sentence with volume 6 For GOOGLE. </prosody></s> 
        <s><prosody volume = "+24dB"> This is a sentence with volume +24 For GOOGLE. </prosody></s>
        <s><prosody volume = "+48dB"> This is a sentence with volume +48 For GOOGLE.</prosody></s> <s><prosody volume = "+196dB"> This is a sentence with volume +196 For GOOGLE.</prosody></s>
    </speak>
    

    TTS UI 上,它确实按预期工作。

    您可以从那里将其导出为 JSON(也许对您有帮助)。

    {
      "audioConfig": {
        "audioEncoding": "LINEAR16",
        "pitch": 0,
        "speakingRate": 1
      },
      "input": {
        "ssml": "<speak> <prosody volume = \"+0dB\"> This is a sentence with volume 10 For GOOGLE. </prosody> <s><prosody volume = \"+6dB\"> This is a sentence with volume 6 For GOOGLE. </prosody></s> <s><prosody volume = \"+24dB\"> This is a sentence with volume +24 For GOOGLE. </prosody></s> <s><prosody volume = \"+48dB\"> This is a sentence with volume +48 For GOOGLE.</prosody></s> <s><prosody volume = \"+196dB\"> This is a sentence with volume +196 For GOOGLE.</prosody></s> </speak>"
      },
      "voice": {
        "languageCode": "en-US",
        "name": "en-US-Standard-A"
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多