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
-
Error when calling tts api using Neutral2.
- [INVALID_ARGUMENT: This request contains sentences that are too long. To fix, split up long sentences with sentence ending punctuation e.g. periods.]
-
My string
- 동해물과 백두산이 마르고 닳도록 하느님이 보우하사 우리나라만세 무궁화 삼천리 화려강산 대한사람 대한으로 길이 보전하세 남산위에 저 소나무 철갑을 두른듯 바람서리 불변함은 우리기상 일세 무궁화 삼천리 화려강산 대한사람 대한으로 길이보전하세 가을하늘 공활한데 높고 구름없이 밝은달은 우리가슴 일편단심일세 무궁화 삼천리 화려강산 대한사람 대한으로 길이보전하세
-
The above problem is the same in DEMO.
-
But, when using ko-KR-Standard, it works normally. Should I write Standard? Can’t I use Neural2?
problem 2
-
Error on call after setting languageCode to KR and SsmlGender to MALE.
- INVALID_ARGUMENT: Requested male voice, but voice ko-KR-Neural2-A is a female voice.
-
If name is not set, language_code and gender are not selected.
- Shouldn’t I bring the male voice ko-KR-Nural2-C because I made setSsmlGender MALE? Let me know if I’m wrong.


