Как я могу воспринимать человеческий акцент (Wav enet или Ssml голосов)? - PullRequest
0 голосов
/ 23 апреля 2020

Я использую этот облачный текст Google для речи, как они пишут на своем сайте. https://codelabs.developers.google.com/codelabs/cloud-text-speech-csharp/#6)

Но нет никаких подробностей о том, как принять выходные Wav enet голоса (Ssml). Этот вывод кодирования - нормальные голоса.

Мой вопрос, с помощью этого кода, как я могу воспринимать человеческий акцент (Wav enet или Ssml voieces)?

using Google.Cloud.TextToSpeech.V1;
using System;
using System.IO;

namespace TextToSpeechApiDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = TextToSpeechClient.Create();

            // The input to be synthesized, can be provided as text or SSML.
            var input = new SynthesisInput
            {
                **Text = "This is a demonstration of the Google Cloud Text-to-Speech API"
            };
            // 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.Mp3
            };

            // 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.mp3"))
            {
                response.AudioContent.WriteTo(output);
            }
            Console.WriteLine("Audio content written to file \"output.mp3\"");
        }
    }
}

1 Ответ

0 голосов
/ 05 мая 2020

Здесь вы можете проверить языки и голоса, поддерживаемые в текстовом API. Как описано в этом уроке речь характеризуется тремя параметрами: language_code, name и ssml_gender.

Вы можете использовать следующий код Python для перевода текста "Hello my name is John. How are you?" на английский sh с ударением en-GB-Standard-A

 def synthesize_text(text):                                                                                                                                                                       
     """Synthesizes speech from the input string of text."""                                                                                                                                      
     from google.cloud import texttospeech                                                                                                                                                        
     client = texttospeech.TextToSpeechClient()                                                                                                                                                   

     input_text = texttospeech.types.SynthesisInput(text=text)                                                                                                                                    

     # Note: the voice can also be specified by name.                                                                                                                                             
     # Names of voices can be retrieved with client.list_voices().                                                                                                                                
     voice = texttospeech.types.VoiceSelectionParams(                                                                                                                                             
         language_code='en-GB',                                                                                                                                                                   
         name='en-GB-Standard-A',                                                                                                                                                                 
         ssml_gender=texttospeech.enums.SsmlVoiceGender.FEMALE)                                                                                                                                   

     audio_config = texttospeech.types.AudioConfig(                                                                                                                                               
         audio_encoding=texttospeech.enums.AudioEncoding.MP3)                                                                                                                                     

     response = client.synthesize_speech(input_text, voice, audio_config)                                                                                                                         

     # The response's audio_content is binary.                                                                                                                                                    
     with open('output.mp3', 'wb') as out:                                                                                                                                                        
         out.write(response.audio_content)                                                                                                                                                        
         print('Audio content written to file "output.mp3"')                                                                                                                                      


 text="Hello my name is John. How are you?"                                                                                         
 synthesize_text(text)

Я не знаком с C# на языке, но, судя по документациям C# и java, вы также сможете определить параметр имени для настройки речи.

...