Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Problems with using ko-KR-Neural2 in tts API.

 

 

		SynthesisInput synthesisInput = SynthesisInput.newBuilder()
			.setText(textToSpeechRequest.getMessage())
			.build();
		AudioConfig audioConfig = AudioConfig.newBuilder()
			.setAudioEncoding(AudioEncoding.LINEAR16)
			.build();

		VoiceSelectionParams voiceSelectionParams = VoiceSelectionParams.newBuilder()
			.setLanguageCode("ko-KR")
			.setSsmlGender(SsmlVoiceGender.MALE)
			// .setName("ko-KR-Standard-A")
			.build();
		SynthesizeSpeechRequest synthesizeSpeechRequest = SynthesizeSpeechRequest.newBuilder()
			.setInput(synthesisInput)
			.setAudioConfig(audioConfig)
			.setVoice(voiceSelectionParams)
			.build();

		SynthesizeSpeechResponse speechResponse = textToSpeechClient.synthesizeSpeech(synthesizeSpeechRequest);

 

 

This is my tts code.  Currently, I have two problems that I can't solve.

problem 1

  1. Error when calling tts api using Neutral2.
    1. [INVALID_ARGUMENT: This request contains sentences that are too long. To fix, split up long sentences with sentence ending punctuation e.g. periods.]
  2. My string
    1. 동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라만세 무궁화 삼천리 화려강산 대한사람 대한으로 길이 보전하세 남산위에 저 소나무 철갑을 두른듯 바람서리 불변함은 우리기상 일세 무궁화 삼천리 화려강산 대한사람 대한으로 길이보전하세 가을하늘 공활한데 높고 구름없이 밝은달은 우리가슴 일편단심일세 무궁화 삼천리 화려강산 대한사람 대한으로 길이보전하세
  3. The above problem is the same in DEMO.
    1. virnectjt_2-1686550771471.png
  4. But, when using ko-KR-Standard, it works normally. Should I write Standard? Can't I use Neural2?

problem 2

  1. Error on call after setting languageCode to KR and SsmlGender to MALE.  
    1. INVALID_ARGUMENT: Requested male voice, but voice ko-KR-Neural2-A is a female voice.​
  2. If name is not set, language_code and gender are not selected.
    1. Shouldn't I bring the male voice ko-KR-Nural2-C because I made setSsmlGender MALE? Let me know if I'm wrong.
    2.  virnectjt_0-1686548463974.png
0 2 625
2 REPLIES 2

You should set the voice name to "ko-KR-Neural2-C" since you are using the Korean (South Korea) language in MALE. You can view this documentation for reference.

virnectjt_0-1686701864493.png

According to the comments above,
If you don't set the name, it says you will choose language_code and gender, but does this function not work?

I understood this when I set the gender to MALE and Language_code to ko,
Automatically select the voice name as ko-KR-Neural2-C.