C#Google Cloud文字转语音-Wavenet问题

时间:2020-09-29 11:11:17

标签: c# audio google-cloud-platform cloud text-to-speech

尊敬的堆栈

尽管使用im的代码未使用“我认为”的wavenet,但我仍在Google Cloud上收取使用Wavenet的费用,如果我使用Wavenet,是否可以禁用它? >

这是我的代码:

// [START tts_synthesize_text]
    /// <summary>
    /// Creates an audio file from the text input.
    /// </summary>
    /// <param name="text">Text to synthesize into audio</param>
    /// <remarks>
    /// Generates a file named 'output.mp3' in project folder.
    /// </remarks>
    public static void SynthesizeText(string text, string filename)
    {
        TextToSpeechClient client = TextToSpeechClient.Create();
        var response = client.SynthesizeSpeech(new SynthesizeSpeechRequest
        {
            Input = new SynthesisInput
            {
                Text = text
            },
            // Note: voices can also be specified by name
            Voice = new VoiceSelectionParams
            {
                LanguageCode = "en-US",
                SsmlGender = SsmlVoiceGender.Female
            },
            AudioConfig = new AudioConfig
            {
                AudioEncoding = AudioEncoding.Mp3,
                SpeakingRate = 0.75
            }
        });

        using (Stream output = File.Create(filename))
        {
            response.AudioContent.WriteTo(output);
        }
    }

enter image description here

1 个答案:

答案 0 :(得分:2)

根据pricing页,向您收取WaveNet语音的费用(减去100万的免费配额,0.2673 * 16 = 4.28)。由于“ VoiceSelectionParams”中的“名称”参数为空,因此自动设置了WaveNet声音。您需要指定一个“名称”参数,否则“该服务将根据其他参数(例如language_code和性别)选择语音。”您可以在“语音名称”列中找到here的语音名称。

相关问题