From 85e395b1392549c43fd5cca2837620ec7d4a481c Mon Sep 17 00:00:00 2001 From: nnegrey Date: Mon, 30 Sep 2019 11:46:52 -0600 Subject: [PATCH 1/3] Lint fix --- .../src/main/java/com/example/texttospeech/SsmlAddresses.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java b/texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java index a8bbfb0e9de..7a9a0d56362 100644 --- a/texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java +++ b/texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java @@ -52,7 +52,7 @@ public class SsmlAddresses { * function saves the synthetic audio to the designated output file. * * @param ssmlText: String of tagged SSML text - * @param outfile: String name of file under which to save audio output + * @param outFile: String name of file under which to save audio output * @throws Exception on errors while closing the client * */ @@ -104,7 +104,7 @@ public static void ssmlToAudio(String ssmlText, String outFile) * of the text file. This function also handles special text characters which might * interfere with SSML commands. * - * @param inputfile: String name of plaintext file + * @param inputFile: String name of plaintext file * @throws IOException on files that don't exist * @return a String of SSML text based on plaintext input. * From 9916679eb8398d555474c8616d121538102d1b65 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Tue, 1 Oct 2019 09:59:36 -0600 Subject: [PATCH 2/3] Lint fix --- .../main/java/com/example/texttospeech/SsmlAddresses.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java b/texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java index 7a9a0d56362..ec47667d3e7 100644 --- a/texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java +++ b/texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java @@ -51,8 +51,8 @@ public class SsmlAddresses { * version of the text, formatted according to the SSML commands. This * function saves the synthetic audio to the designated output file. * - * @param ssmlText: String of tagged SSML text - * @param outFile: String name of file under which to save audio output + * @param ssmlText String of tagged SSML text + * @param outFile String name of file under which to save audio output * @throws Exception on errors while closing the client * */ @@ -104,7 +104,7 @@ public static void ssmlToAudio(String ssmlText, String outFile) * of the text file. This function also handles special text characters which might * interfere with SSML commands. * - * @param inputFile: String name of plaintext file + * @param inputFile String name of plaintext file * @throws IOException on files that don't exist * @return a String of SSML text based on plaintext input. * From 537df04a2804fa2112b4613a242ec072337cb158 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Tue, 1 Oct 2019 11:05:46 -0600 Subject: [PATCH 3/3] Run google-java-format script --- .../example/texttospeech/SsmlAddresses.java | 56 ++++++++----------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java b/texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java index ec47667d3e7..1e75b408a15 100644 --- a/texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java +++ b/texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java @@ -34,11 +34,9 @@ import java.nio.file.Paths; // [END tts_ssml_address_imports] - /** - * Google Cloud TextToSpeech API sample application. - * Example usage: mvn package exec:java - * -Dexec.mainClass='com.example.texttospeech.SsmlAddresses + * Google Cloud TextToSpeech API sample application. Example usage: mvn package exec:java + * -Dexec.mainClass='com.example.texttospeech.SsmlAddresses */ public class SsmlAddresses { @@ -46,41 +44,36 @@ public class SsmlAddresses { /** * Generates synthetic audio from a String of SSML text. * - * Given a string of SSML text and an output file name, this function - * calls the Text-to-Speech API. The API returns a synthetic audio - * version of the text, formatted according to the SSML commands. This - * function saves the synthetic audio to the designated output file. + *

Given a string of SSML text and an output file name, this function calls the Text-to-Speech + * API. The API returns a synthetic audio version of the text, formatted according to the SSML + * commands. This function saves the synthetic audio to the designated output file. * * @param ssmlText String of tagged SSML text * @param outFile String name of file under which to save audio output * @throws Exception on errors while closing the client - * */ - public static void ssmlToAudio(String ssmlText, String outFile) - throws Exception { + public static void ssmlToAudio(String ssmlText, String outFile) throws Exception { // Instantiates a client try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) { // Set the ssml text input to synthesize - SynthesisInput input = SynthesisInput.newBuilder() - .setSsml(ssmlText) - .build(); + SynthesisInput input = SynthesisInput.newBuilder().setSsml(ssmlText).build(); // Build the voice request, select the language code ("en-US") and // the ssml voice gender ("male") - VoiceSelectionParams voice = VoiceSelectionParams.newBuilder() - .setLanguageCode("en-US") - .setSsmlGender(SsmlVoiceGender.MALE) - .build(); + VoiceSelectionParams voice = + VoiceSelectionParams.newBuilder() + .setLanguageCode("en-US") + .setSsmlGender(SsmlVoiceGender.MALE) + .build(); // Select the audio file type - AudioConfig audioConfig = AudioConfig.newBuilder() - .setAudioEncoding(AudioEncoding.MP3) - .build(); + AudioConfig audioConfig = + AudioConfig.newBuilder().setAudioEncoding(AudioEncoding.MP3).build(); // Perform the text-to-speech request on the text input with the selected voice parameters and // audio file type - 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(); @@ -98,19 +91,16 @@ public static void ssmlToAudio(String ssmlText, String outFile) /** * Generates SSML text from plaintext. * - * Given an input filename, this function converts the contents of the input text file - * into a String of tagged SSML text. This function formats the SSML String so that, - * when synthesized, the synthetic audio will pause for two seconds between each line - * of the text file. This function also handles special text characters which might - * interfere with SSML commands. + *

Given an input filename, this function converts the contents of the input text file into a + * String of tagged SSML text. This function formats the SSML String so that, when synthesized, + * the synthetic audio will pause for two seconds between each line of the text file. This + * function also handles special text characters which might interfere with SSML commands. * * @param inputFile String name of plaintext file - * @throws IOException on files that don't exist * @return a String of SSML text based on plaintext input. - * + * @throws IOException on files that don't exist */ - public static String textToSsml(String inputFile) - throws Exception { + public static String textToSsml(String inputFile) throws Exception { // Read lines of input file String rawLines = new String(Files.readAllBytes(Paths.get(inputFile))); @@ -122,7 +112,7 @@ public static String textToSsml(String inputFile) // Convert plaintext to SSML // Tag SSML so that there is a 2 second pause between each address - String expandedNewline = escapedLines.replaceAll("\\n","\n"); + String expandedNewline = escapedLines.replaceAll("\\n", "\n"); String ssml = "" + expandedNewline + ""; // Return the concatenated String of SSML