コード例 #1
0
    def test_make_params_with_voice_config_only(self):
        for l in GoogleClient.AVAILABLE_LANGUAGES:
            for g in GoogleClient.GENDER_DICT:
                vc = VoiceConfig(language=l, gender=g)
                params = self.c._make_params(vc, None)

                self.assertEqual(params['gender'], GoogleClient.GENDER_DICT[g])
                self.assertEqual(params['language'], l.value)
コード例 #2
0
    def test_make_params_with_voice_config_and_detail(self):
        detail = {
            'accept': 'audio/ogg;codecs=opus;rate=192000',
            'voice': 'en-US_MichaelVoice'
        }
        vc = VoiceConfig(audio_format=AudioFormat.mp3, gender=Gender.female)
        params = self.c._make_params(vc, detail)

        # detail overwrites values
        self.assertNotEqual(params['accept'], 'mp3')
        self.assertEqual(params['accept'], detail['accept'])

        self.assertNotEqual(params['voice'], 'en-US_AllisonVoice')
        self.assertEqual(params['voice'], detail['voice'])
コード例 #3
0
    def test_make_params_with_voice_config_and_detail(self):
        detail = {
            'output_format': 'pcm',
            'sample_rate': '16000',
            'voice_id': 'Kendra'
        }
        vc = VoiceConfig(audio_format=AudioFormat.mp3, gender=Gender.female)
        params = self.c._make_params(vc, detail)

        # detail overwrites values
        self.assertNotEqual(params['output_format'], 'mp3')
        self.assertEqual(params['output_format'], detail['output_format'])

        self.assertNotEqual(params['voice_id'], 'Joanna')
        self.assertEqual(params['voice_id'], detail['voice_id'])
コード例 #4
0
ファイル: test_microsoft.py プロジェクト: setomits/cloudtts
    def test_make_params_with_voice_config_and_detail(self):
        vc = VoiceConfig(audio_format=AudioFormat.mp3,
                         gender=Gender.female,
                         language=Language.en_US)
        detail = {
            'format': 'ssml-16khz-16bit-mono-tts',
            'gender': 'male',
            'language': 'ja-JP',
            'voice': 'Ichiro, Apollo'
        }

        params = self.c._make_params(vc, detail)

        # detail overwrites values
        self.assertNotEqual(params['format'],
                            'audio-16khz-128kbitrate-mono-mp3')
        self.assertEqual(params['format'], detail['format'])

        self.assertNotEqual(params['voice'], 'ZiraRUS')
        self.assertEqual(params['voice'], detail['voice'])
コード例 #5
0
    def test_make_params_with_voice_config_and_detail(self):
        detail = {'audio_encoding': texttospeech.enums.AudioEncoding.OGG_OPUS,
                  'gender': texttospeech.enums.SsmlVoiceGender.NEUTRAL,
                  'language': 'ja-JP'}
        vc = VoiceConfig(audio_format=AudioFormat.mp3,
                         gender=Gender.female,
                         language=Language.it_IT)
        params = self.c._make_params(vc, detail)

        # detail overwrites values
        self.assertNotEqual(params['audio_encoding'],
                            texttospeech.enums.AudioEncoding.MP3)
        self.assertEqual(params['audio_encoding'], detail['audio_encoding'])

        self.assertNotEqual(params['gender'],
                            texttospeech.enums.SsmlVoiceGender.FEMALE)
        self.assertEqual(params['gender'], detail['gender'])

        self.assertNotEqual(params['language'], 'it-IT')
        self.assertEqual(params['language'], detail['language'])
コード例 #6
0
 def test_make_params_with_voice_config_only(self):
     for l, g in WatsonClient.LANG_GENDER_DICT:
         vc = VoiceConfig(language=l, gender=g)
         params = self.c._make_params(vc, None)
         voice = WatsonClient.LANG_GENDER_DICT[(l, g)]
         self.assertEqual(params['voice'], voice)
コード例 #7
0
ファイル: sample.py プロジェクト: setomits/cloudtts
from cloudtts import AzureClient, AzureCredential
from cloudtts import GoogleClient
from cloudtts import PollyClient, PollyCredential
from cloudtts import WatsonClient, WatsonCredential

from cloudtts import VoiceConfig
from cloudtts import Gender
from cloudtts import Language

enVC = VoiceConfig()
jaVC = VoiceConfig(language=Language.ja_JP, gender=Gender.male)


def _azure():
    cred = AzureCredential(api_key='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
    c = AzureClient(cred)

    # English US
    audio = c.tts('Hi there, it is too hot today.', voice_config=enVC)
    with open('azure_hot_en.mp3', 'wb') as f:
        f.close(audio)

    # English US with SSML
    audio = c.tts(
        '<speak>Hi there,<break time="1s" /> it is too hot today.</speak>',
        voice_config=enVC)
    with open('azure_hot_en_ssml.mp3', 'wb') as f:
        f.close(audio)

    # Japanese
    audio = c.tts('今日はすごく暑いですね。', voice_config=jaVC)