Skip to content

Commit decd51a

Browse files
nnegreyandrewferlitsch
authored andcommitted
Lint fix (#1594)
* Lint fix * Lint fix * Run google-java-format script
1 parent 98f2d89 commit decd51a

File tree

1 file changed

+26
-36
lines changed

1 file changed

+26
-36
lines changed

texttospeech/cloud-client/src/main/java/com/example/texttospeech/SsmlAddresses.java

+26-36
Original file line numberDiff line numberDiff line change
@@ -34,53 +34,46 @@
3434
import java.nio.file.Paths;
3535
// [END tts_ssml_address_imports]
3636

37-
3837
/**
39-
* Google Cloud TextToSpeech API sample application.
40-
* Example usage: mvn package exec:java
41-
* -Dexec.mainClass='com.example.texttospeech.SsmlAddresses
38+
* Google Cloud TextToSpeech API sample application. Example usage: mvn package exec:java
39+
* -Dexec.mainClass='com.example.texttospeech.SsmlAddresses
4240
*/
4341
public class SsmlAddresses {
4442

4543
// [START tts_ssml_address_audio]
4644
/**
4745
* Generates synthetic audio from a String of SSML text.
4846
*
49-
* Given a string of SSML text and an output file name, this function
50-
* calls the Text-to-Speech API. The API returns a synthetic audio
51-
* version of the text, formatted according to the SSML commands. This
52-
* function saves the synthetic audio to the designated output file.
47+
* <p>Given a string of SSML text and an output file name, this function calls the Text-to-Speech
48+
* API. The API returns a synthetic audio version of the text, formatted according to the SSML
49+
* commands. This function saves the synthetic audio to the designated output file.
5350
*
54-
* @param ssmlText: String of tagged SSML text
55-
* @param outfile: String name of file under which to save audio output
51+
* @param ssmlText String of tagged SSML text
52+
* @param outFile String name of file under which to save audio output
5653
* @throws Exception on errors while closing the client
57-
*
5854
*/
59-
public static void ssmlToAudio(String ssmlText, String outFile)
60-
throws Exception {
55+
public static void ssmlToAudio(String ssmlText, String outFile) throws Exception {
6156
// Instantiates a client
6257
try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
6358
// Set the ssml text input to synthesize
64-
SynthesisInput input = SynthesisInput.newBuilder()
65-
.setSsml(ssmlText)
66-
.build();
59+
SynthesisInput input = SynthesisInput.newBuilder().setSsml(ssmlText).build();
6760

6861
// Build the voice request, select the language code ("en-US") and
6962
// the ssml voice gender ("male")
70-
VoiceSelectionParams voice = VoiceSelectionParams.newBuilder()
71-
.setLanguageCode("en-US")
72-
.setSsmlGender(SsmlVoiceGender.MALE)
73-
.build();
63+
VoiceSelectionParams voice =
64+
VoiceSelectionParams.newBuilder()
65+
.setLanguageCode("en-US")
66+
.setSsmlGender(SsmlVoiceGender.MALE)
67+
.build();
7468

7569
// Select the audio file type
76-
AudioConfig audioConfig = AudioConfig.newBuilder()
77-
.setAudioEncoding(AudioEncoding.MP3)
78-
.build();
70+
AudioConfig audioConfig =
71+
AudioConfig.newBuilder().setAudioEncoding(AudioEncoding.MP3).build();
7972

8073
// Perform the text-to-speech request on the text input with the selected voice parameters and
8174
// audio file type
82-
SynthesizeSpeechResponse response = textToSpeechClient.synthesizeSpeech(input, voice,
83-
audioConfig);
75+
SynthesizeSpeechResponse response =
76+
textToSpeechClient.synthesizeSpeech(input, voice, audioConfig);
8477

8578
// Get the audio contents from the response
8679
ByteString audioContents = response.getAudioContent();
@@ -98,19 +91,16 @@ public static void ssmlToAudio(String ssmlText, String outFile)
9891
/**
9992
* Generates SSML text from plaintext.
10093
*
101-
* Given an input filename, this function converts the contents of the input text file
102-
* into a String of tagged SSML text. This function formats the SSML String so that,
103-
* when synthesized, the synthetic audio will pause for two seconds between each line
104-
* of the text file. This function also handles special text characters which might
105-
* interfere with SSML commands.
94+
* <p>Given an input filename, this function converts the contents of the input text file into a
95+
* String of tagged SSML text. This function formats the SSML String so that, when synthesized,
96+
* the synthetic audio will pause for two seconds between each line of the text file. This
97+
* function also handles special text characters which might interfere with SSML commands.
10698
*
107-
* @param inputfile: String name of plaintext file
108-
* @throws IOException on files that don't exist
99+
* @param inputFile String name of plaintext file
109100
* @return a String of SSML text based on plaintext input.
110-
*
101+
* @throws IOException on files that don't exist
111102
*/
112-
public static String textToSsml(String inputFile)
113-
throws Exception {
103+
public static String textToSsml(String inputFile) throws Exception {
114104

115105
// Read lines of input file
116106
String rawLines = new String(Files.readAllBytes(Paths.get(inputFile)));
@@ -122,7 +112,7 @@ public static String textToSsml(String inputFile)
122112

123113
// Convert plaintext to SSML
124114
// Tag SSML so that there is a 2 second pause between each address
125-
String expandedNewline = escapedLines.replaceAll("\\n","\n<break time='2s'/>");
115+
String expandedNewline = escapedLines.replaceAll("\\n", "\n<break time='2s'/>");
126116
String ssml = "<speak>" + expandedNewline + "</speak>";
127117

128118
// Return the concatenated String of SSML

0 commit comments

Comments
 (0)