From 748be1bd3595ce52689eed40f365a66f9415912d Mon Sep 17 00:00:00 2001 From: Nirupa Anantha Kumar Date: Fri, 20 Jul 2018 10:51:23 -0700 Subject: [PATCH] samples: Adding TTS Beta samples : Audio profile (#1152) * Adding TTS Beta samples : Audio profile * Updated based on comments : Adding TTS Beta samples - Audio profile * Updated based on comments : TTS Beta samples - Audio profile * Updated based on comments : TTS Beta samples - Audio profile * Updates after review * Updates after review * Updates after review : Please let this be the last one :) * Update to released client library * Update SynthesizeText.java Need to update the verification script to allow LLC. * Update SynthesizeText.java Need to update the verification script to allow LLC. --- .../example/texttospeech/SynthesizeText.java | 72 ++++++++++--------- .../texttospeech/SynthesizeTextIT.java | 2 +- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/texttospeech/snippets/src/main/java/com/example/texttospeech/SynthesizeText.java b/texttospeech/snippets/src/main/java/com/example/texttospeech/SynthesizeText.java index c447b69c028..3b7b8960824 100644 --- a/texttospeech/snippets/src/main/java/com/example/texttospeech/SynthesizeText.java +++ b/texttospeech/snippets/src/main/java/com/example/texttospeech/SynthesizeText.java @@ -37,39 +37,39 @@ /** * Google Cloud TextToSpeech API sample application. * Example usage: mvn package exec:java -Dexec.mainClass='com.example.texttospeech.SynthesizeText' - * -Dexec.args='text "hello"' + * -Dexec.args='--text "hello"' */ public class SynthesizeText { // [START tts_synthesize_text] /** * Demonstrates using the Text to Speech client to synthesize text or ssml. + * * @param text the raw text to be synthesized. (e.g., "Hello there!") * @throws Exception on TextToSpeechClient Errors. */ - public static void synthesizeText(String text) - throws Exception { + public static void synthesizeText(String text) throws Exception { // Instantiates a client try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) { // Set the text input to be synthesized - SynthesisInput input = SynthesisInput.newBuilder() - .setText(text) - .build(); + SynthesisInput input = SynthesisInput.newBuilder().setText(text).build(); // Build the voice request - VoiceSelectionParams voice = VoiceSelectionParams.newBuilder() - .setLanguageCode("en-US") // languageCode = "en_us" - .setSsmlGender(SsmlVoiceGender.FEMALE) // ssmlVoiceGender = SsmlVoiceGender.FEMALE - .build(); + VoiceSelectionParams voice = + VoiceSelectionParams.newBuilder() + .setLanguageCode("en-US") // languageCode = "en_us" + .setSsmlGender(SsmlVoiceGender.FEMALE) // ssmlVoiceGender = SsmlVoiceGender.FEMALE + .build(); // Select the type of audio file you want returned - AudioConfig audioConfig = AudioConfig.newBuilder() - .setAudioEncoding(AudioEncoding.MP3) // MP3 audio. - .build(); + AudioConfig audioConfig = + AudioConfig.newBuilder() + .setAudioEncoding(AudioEncoding.MP3) // MP3 audio. + .build(); // Perform the text-to-speech request - SynthesizeSpeechResponse response = textToSpeechClient.synthesizeSpeech(input, voice, - audioConfig); + SynthesizeSpeechResponse response = + textToSpeechClient.synthesizeSpeech(input, voice, audioConfig); // Get the audio contents from the response ByteString audioContents = response.getAudioContent(); @@ -87,34 +87,34 @@ public static void synthesizeText(String text) /** * Demonstrates using the Text to Speech client to synthesize text or ssml. * - * Note: ssml must be well-formed according to: (https://www.w3.org/TR/speech-synthesis/ + *

Note: ssml must be well-formed according to: (https://www.w3.org/TR/speech-synthesis/ * Example: Hello there. + * * @param ssml the ssml document to be synthesized. (e.g., "