From be1c72ef302d012d563934b292458c432974f7af Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Sat, 1 Jan 2022 16:56:09 +0100 Subject: [PATCH 1/2] Improve exception handling Signed-off-by: Christoph Weitkamp --- .../internal/AuthenticationException.java | 34 ----- .../googletts/internal/GoogleCloudAPI.java | 120 +++++++++++------- .../googletts/internal/GoogleTTSService.java | 2 +- 3 files changed, 76 insertions(+), 80 deletions(-) delete mode 100644 bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/AuthenticationException.java diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/AuthenticationException.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/AuthenticationException.java deleted file mode 100644 index b95791722234e..0000000000000 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/AuthenticationException.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2010-2021 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.voice.googletts.internal; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * Thrown, if an authentication error is given. - * - * @author Christoph Weitkamp - Initial contribution - * - */ -@NonNullByDefault -public class AuthenticationException extends Exception { - - private static final long serialVersionUID = 1L; - - public AuthenticationException() { - } - - public AuthenticationException(String message) { - super(message); - } -} diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleCloudAPI.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleCloudAPI.java index 766b894c93724..174574274cc3c 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleCloudAPI.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleCloudAPI.java @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; -import java.util.Collections; import java.util.Dictionary; import java.util.HashMap; import java.util.HashSet; @@ -37,11 +36,13 @@ import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.MimeTypes; import org.openhab.core.audio.AudioFormat; +import org.openhab.core.auth.AuthenticationException; import org.openhab.core.auth.client.oauth2.AccessTokenResponse; import org.openhab.core.auth.client.oauth2.OAuthClientService; import org.openhab.core.auth.client.oauth2.OAuthException; import org.openhab.core.auth.client.oauth2.OAuthFactory; import org.openhab.core.auth.client.oauth2.OAuthResponseException; +import org.openhab.core.i18n.CommunicationException; import org.openhab.core.io.net.http.HttpRequestBuilder; import org.openhab.voice.googletts.internal.protocol.AudioConfig; import org.openhab.voice.googletts.internal.protocol.AudioEncoding; @@ -59,6 +60,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonSyntaxException; /** * Google Cloud TTS API call implementation. @@ -152,8 +154,8 @@ void setConfig(GoogleTTSConfig config) { getAccessToken(); initialized = true; initVoices(); - } catch (AuthenticationException | IOException ex) { - logger.warn("Error initializing Google Cloud TTS service: {}", ex.getMessage()); + } catch (AuthenticationException | CommunicationException e) { + logger.warn("Error initializing Google Cloud TTS service: {}", e.getMessage()); oAuthService = null; initialized = false; voices.clear(); @@ -177,17 +179,24 @@ void setConfig(GoogleTTSConfig config) { /** * Fetches the OAuth2 tokens from Google Cloud Platform if the auth-code is set in the configuration. If successful * the auth-code will be removed from the configuration. + * + * @throws AuthenticationException + * @throws CommunicationException */ - private void getAccessToken() throws AuthenticationException, IOException { + @SuppressWarnings("null") + private void getAccessToken() throws AuthenticationException, CommunicationException { String authcode = config.authcode; if (authcode != null && !authcode.isEmpty()) { logger.debug("Trying to get access and refresh tokens."); try { oAuthService.getAccessTokenResponseByAuthorizationCode(authcode, GCP_REDIRECT_URI); - } catch (OAuthException | OAuthResponseException ex) { - logger.debug("Error fetching access token: {}", ex.getMessage(), ex); + } catch (OAuthException | OAuthResponseException e) { + logger.debug("Error fetching access token: {}", e.getMessage(), e); throw new AuthenticationException( "Error fetching access token. Invalid authcode? Please generate a new one."); + } catch (IOException e) { + throw new CommunicationException( + String.format("An unexpected IOException occured: %s", e.getMessage())); } config.authcode = null; @@ -207,14 +216,17 @@ private void getAccessToken() throws AuthenticationException, IOException { } } - private String getAuthorizationHeader() throws AuthenticationException, IOException { + @SuppressWarnings("null") + private String getAuthorizationHeader() throws AuthenticationException, CommunicationException { final AccessTokenResponse accessTokenResponse; try { accessTokenResponse = oAuthService.getAccessTokenResponse(); - } catch (OAuthException | OAuthResponseException ex) { - logger.debug("Error fetching access token: {}", ex.getMessage(), ex); + } catch (OAuthException | OAuthResponseException e) { + logger.debug("Error fetching access token: {}", e.getMessage(), e); throw new AuthenticationException( "Error fetching access token. Invalid authcode? Please generate a new one."); + } catch (IOException e) { + throw new CommunicationException(String.format("An unexpected IOException occured: %s", e.getMessage())); } if (accessTokenResponse == null || accessTokenResponse.getAccessToken() == null || accessTokenResponse.getAccessToken().isEmpty()) { @@ -255,13 +267,16 @@ Set getSupportedLocales() { */ Set getVoicesForLocale(Locale locale) { Set localeVoices = voices.get(locale); - return localeVoices != null ? localeVoices : Collections.emptySet(); + return localeVoices != null ? localeVoices : Set.of(); } /** * Google API call to load locales and voices. + * + * @throws AuthenticationException + * @throws CommunicationException */ - private void initVoices() throws AuthenticationException, IOException { + private void initVoices() throws AuthenticationException, CommunicationException { if (oAuthService != null) { voices.clear(); for (GoogleTTSVoice voice : listVoices()) { @@ -281,25 +296,32 @@ private void initVoices() throws AuthenticationException, IOException { } @SuppressWarnings("null") - private List listVoices() throws AuthenticationException, IOException { + private List listVoices() throws AuthenticationException, CommunicationException { HttpRequestBuilder builder = HttpRequestBuilder.getFrom(LIST_VOICES_URL) .withHeader(HttpHeader.AUTHORIZATION.name(), getAuthorizationHeader()); - ListVoicesResponse listVoicesResponse = gson.fromJson(builder.getContentAsString(), ListVoicesResponse.class); + try { + ListVoicesResponse listVoicesResponse = gson.fromJson(builder.getContentAsString(), + ListVoicesResponse.class); - if (listVoicesResponse == null || listVoicesResponse.getVoices() == null) { - return Collections.emptyList(); - } + if (listVoicesResponse == null || listVoicesResponse.getVoices() == null) { + return List.of(); + } - List result = new ArrayList<>(); - for (Voice voice : listVoicesResponse.getVoices()) { - for (String languageCode : voice.getLanguageCodes()) { - result.add(new GoogleTTSVoice(Locale.forLanguageTag(languageCode), voice.getName(), - voice.getSsmlGender().name())); + List result = new ArrayList<>(); + for (Voice voice : listVoicesResponse.getVoices()) { + for (String languageCode : voice.getLanguageCodes()) { + result.add(new GoogleTTSVoice(Locale.forLanguageTag(languageCode), voice.getName(), + voice.getSsmlGender().name())); + } } + return result; + } catch (JsonSyntaxException e) { + // do nothing + } catch (IOException e) { + throw new CommunicationException(String.format("An unexpected IOException occured: %s", e.getMessage())); } - - return result; + return List.of(); } /** @@ -319,7 +341,7 @@ private String[] getFormatForCodec(String codec) { } } - byte[] synthesizeSpeech(String text, GoogleTTSVoice voice, String codec) { + public byte[] synthesizeSpeech(String text, GoogleTTSVoice voice, String codec) { String[] format = getFormatForCodec(codec); String fileNameInCache = getUniqueFilenameForText(text, voice.getTechnicalName()); File audioFileInCache = new File(cacheFolder, fileNameInCache + "." + format[1]); @@ -336,19 +358,17 @@ byte[] synthesizeSpeech(String text, GoogleTTSVoice voice, String codec) { saveAudioAndTextToFile(text, audioFileInCache, audio, voice.getTechnicalName()); } return audio; - } catch (AuthenticationException ex) { - logger.warn("Error initializing Google Cloud TTS service: {}", ex.getMessage()); + } catch (AuthenticationException | CommunicationException e) { + logger.warn("Error initializing Google Cloud TTS service: {}", e.getMessage()); oAuthService = null; initialized = false; voices.clear(); - return null; - } catch (FileNotFoundException ex) { - logger.warn("Could not write {} to cache", audioFileInCache, ex); - return null; - } catch (IOException ex) { - logger.error("Could not write {} to cache", audioFileInCache, ex); - return null; + } catch (FileNotFoundException e) { + logger.warn("Could not write file {} to cache: ", audioFileInCache, e.getMessage()); + } catch (IOException e) { + logger.debug("An unexpected IOException occured: %s", e.getMessage()); } + return null; } /** @@ -358,10 +378,11 @@ byte[] synthesizeSpeech(String text, GoogleTTSVoice voice, String codec) { * @param cacheFile Cache entry file. * @param audio Byte array of the audio. * @param voiceName Used voice + * @throws FileNotFoundException * @throws IOException in case of file handling exceptions */ private void saveAudioAndTextToFile(String text, File cacheFile, byte[] audio, String voiceName) - throws IOException { + throws IOException, FileNotFoundException { logger.debug("Caching audio file {}", cacheFile.getName()); try (FileOutputStream audioFileOutputStream = new FileOutputStream(cacheFile)) { audioFileOutputStream.write(audio); @@ -405,10 +426,12 @@ private String removeExtension(String fileName) { * @param voice Voice parameter * @param audioFormat Audio encoding format * @return Audio input stream or {@code null} when encoding exceptions occur + * @throws AuthenticationException + * @throws CommunicationException */ - @SuppressWarnings({ "null", "unused" }) + @SuppressWarnings("null") private byte[] synthesizeSpeechByGoogle(String text, GoogleTTSVoice voice, String audioFormat) - throws AuthenticationException, IOException { + throws AuthenticationException, CommunicationException { AudioConfig audioConfig = new AudioConfig(AudioEncoding.valueOf(audioFormat), config.pitch, config.speakingRate, config.volumeGainDb); SynthesisInput synthesisInput = new SynthesisInput(text); @@ -422,15 +445,22 @@ private byte[] synthesizeSpeechByGoogle(String text, GoogleTTSVoice voice, Strin .withHeader(HttpHeader.AUTHORIZATION.name(), getAuthorizationHeader()) .withContent(gson.toJson(request), MimeTypes.Type.APPLICATION_JSON.name()); - SynthesizeSpeechResponse synthesizeSpeechResponse = gson.fromJson(builder.getContentAsString(), - SynthesizeSpeechResponse.class); + try { + SynthesizeSpeechResponse synthesizeSpeechResponse = gson.fromJson(builder.getContentAsString(), + SynthesizeSpeechResponse.class); - if (synthesizeSpeechResponse == null) { - return null; - } + if (synthesizeSpeechResponse == null) { + return null; + } - byte[] encodedBytes = synthesizeSpeechResponse.getAudioContent().getBytes(StandardCharsets.UTF_8); - return Base64.getDecoder().decode(encodedBytes); + byte[] encodedBytes = synthesizeSpeechResponse.getAudioContent().getBytes(StandardCharsets.UTF_8); + return Base64.getDecoder().decode(encodedBytes); + } catch (JsonSyntaxException e) { + // do nothing + } catch (IOException e) { + throw new CommunicationException(String.format("An unexpected IOException occured: %s", e.getMessage())); + } + return null; } /** @@ -445,9 +475,9 @@ private String getUniqueFilenameForText(String text, String voiceName) { byte[] bytesOfMessage = (config.toConfigString() + text).getBytes(StandardCharsets.UTF_8); String fileNameHash = String.format("%032x", new BigInteger(1, md.digest(bytesOfMessage))); return voiceName + "_" + fileNameHash; - } catch (NoSuchAlgorithmException ex) { + } catch (NoSuchAlgorithmException e) { // should not happen - logger.error("Could not create MD5 hash for '{}'", text, ex); + logger.error("Could not create MD5 hash for '{}'", text, e); return null; } } diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleTTSService.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleTTSService.java index a96dc4c224262..42083af4574b0 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleTTSService.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleTTSService.java @@ -330,7 +330,7 @@ public AudioStream synthesize(String text, Voice voice, AudioFormat requestedFor // create the audio byte array for given text, locale, format byte[] audio = apiImpl.synthesizeSpeech(trimmedText, (GoogleTTSVoice) voice, requestedFormat.getCodec()); if (audio == null) { - throw new TTSException("Could not read from Google Cloud TTS Service"); + throw new TTSException("Could not synthesize text via Google Cloud TTS Service"); } return new ByteArrayAudioStream(audio, requestedFormat); } From 0e1e54752615ac5af7b85bea87908df66c7c36ed Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Sat, 1 Jan 2022 17:22:29 +0100 Subject: [PATCH 2/2] Moved classes to dto package to reduce SAT warning Signed-off-by: Christoph Weitkamp --- .../googletts/internal/GoogleCloudAPI.java | 30 +++++++++---------- .../googletts/internal/GoogleTTSService.java | 2 +- .../googletts/internal/GoogleTTSVoice.java | 2 +- .../{protocol => dto}/AudioConfig.java | 2 +- .../{protocol => dto}/AudioEncoding.java | 2 +- .../{protocol => dto}/ListVoicesResponse.java | 2 +- .../{protocol => dto}/SsmlVoiceGender.java | 2 +- .../{protocol => dto}/SynthesisInput.java | 2 +- .../SynthesizeSpeechRequest.java | 2 +- .../SynthesizeSpeechResponse.java | 2 +- .../internal/{protocol => dto}/Voice.java | 2 +- .../VoiceSelectionParams.java | 2 +- 12 files changed, 26 insertions(+), 26 deletions(-) rename bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/{protocol => dto}/AudioConfig.java (98%) rename bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/{protocol => dto}/AudioEncoding.java (95%) rename bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/{protocol => dto}/ListVoicesResponse.java (94%) rename bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/{protocol => dto}/SsmlVoiceGender.java (95%) rename bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/{protocol => dto}/SynthesisInput.java (96%) rename bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/{protocol => dto}/SynthesizeSpeechRequest.java (96%) rename bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/{protocol => dto}/SynthesizeSpeechResponse.java (95%) rename bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/{protocol => dto}/Voice.java (96%) rename bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/{protocol => dto}/VoiceSelectionParams.java (98%) diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleCloudAPI.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleCloudAPI.java index 174574274cc3c..76b170e33aff4 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleCloudAPI.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleCloudAPI.java @@ -44,15 +44,15 @@ import org.openhab.core.auth.client.oauth2.OAuthResponseException; import org.openhab.core.i18n.CommunicationException; import org.openhab.core.io.net.http.HttpRequestBuilder; -import org.openhab.voice.googletts.internal.protocol.AudioConfig; -import org.openhab.voice.googletts.internal.protocol.AudioEncoding; -import org.openhab.voice.googletts.internal.protocol.ListVoicesResponse; -import org.openhab.voice.googletts.internal.protocol.SsmlVoiceGender; -import org.openhab.voice.googletts.internal.protocol.SynthesisInput; -import org.openhab.voice.googletts.internal.protocol.SynthesizeSpeechRequest; -import org.openhab.voice.googletts.internal.protocol.SynthesizeSpeechResponse; -import org.openhab.voice.googletts.internal.protocol.Voice; -import org.openhab.voice.googletts.internal.protocol.VoiceSelectionParams; +import org.openhab.voice.googletts.internal.dto.AudioConfig; +import org.openhab.voice.googletts.internal.dto.AudioEncoding; +import org.openhab.voice.googletts.internal.dto.ListVoicesResponse; +import org.openhab.voice.googletts.internal.dto.SsmlVoiceGender; +import org.openhab.voice.googletts.internal.dto.SynthesisInput; +import org.openhab.voice.googletts.internal.dto.SynthesizeSpeechRequest; +import org.openhab.voice.googletts.internal.dto.SynthesizeSpeechResponse; +import org.openhab.voice.googletts.internal.dto.Voice; +import org.openhab.voice.googletts.internal.dto.VoiceSelectionParams; import org.osgi.service.cm.Configuration; import org.osgi.service.cm.ConfigurationAdmin; import org.slf4j.Logger; @@ -196,7 +196,7 @@ private void getAccessToken() throws AuthenticationException, CommunicationExcep "Error fetching access token. Invalid authcode? Please generate a new one."); } catch (IOException e) { throw new CommunicationException( - String.format("An unexpected IOException occured: %s", e.getMessage())); + String.format("An unexpected IOException occurred: %s", e.getMessage())); } config.authcode = null; @@ -226,7 +226,7 @@ private String getAuthorizationHeader() throws AuthenticationException, Communic throw new AuthenticationException( "Error fetching access token. Invalid authcode? Please generate a new one."); } catch (IOException e) { - throw new CommunicationException(String.format("An unexpected IOException occured: %s", e.getMessage())); + throw new CommunicationException(String.format("An unexpected IOException occurred: %s", e.getMessage())); } if (accessTokenResponse == null || accessTokenResponse.getAccessToken() == null || accessTokenResponse.getAccessToken().isEmpty()) { @@ -319,7 +319,7 @@ private List listVoices() throws AuthenticationException, Commun } catch (JsonSyntaxException e) { // do nothing } catch (IOException e) { - throw new CommunicationException(String.format("An unexpected IOException occured: %s", e.getMessage())); + throw new CommunicationException(String.format("An unexpected IOException occurred: %s", e.getMessage())); } return List.of(); } @@ -364,9 +364,9 @@ public byte[] synthesizeSpeech(String text, GoogleTTSVoice voice, String codec) initialized = false; voices.clear(); } catch (FileNotFoundException e) { - logger.warn("Could not write file {} to cache: ", audioFileInCache, e.getMessage()); + logger.warn("Could not write file {} to cache: {}", audioFileInCache, e.getMessage()); } catch (IOException e) { - logger.debug("An unexpected IOException occured: %s", e.getMessage()); + logger.debug("An unexpected IOException occurred: {}", e.getMessage()); } return null; } @@ -458,7 +458,7 @@ private byte[] synthesizeSpeechByGoogle(String text, GoogleTTSVoice voice, Strin } catch (JsonSyntaxException e) { // do nothing } catch (IOException e) { - throw new CommunicationException(String.format("An unexpected IOException occured: %s", e.getMessage())); + throw new CommunicationException(String.format("An unexpected IOException occurred: %s", e.getMessage())); } return null; } diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleTTSService.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleTTSService.java index 42083af4574b0..f7fefc7f7c050 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleTTSService.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleTTSService.java @@ -32,7 +32,7 @@ import org.openhab.core.voice.TTSException; import org.openhab.core.voice.TTSService; import org.openhab.core.voice.Voice; -import org.openhab.voice.googletts.internal.protocol.AudioEncoding; +import org.openhab.voice.googletts.internal.dto.AudioEncoding; import org.osgi.framework.Constants; import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.annotations.Activate; diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleTTSVoice.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleTTSVoice.java index 8cec61fb540bb..611a142b095e9 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleTTSVoice.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/GoogleTTSVoice.java @@ -16,7 +16,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.voice.Voice; -import org.openhab.voice.googletts.internal.protocol.SsmlVoiceGender; +import org.openhab.voice.googletts.internal.dto.SsmlVoiceGender; /** * Implementation of the Voice interface for Google Cloud TTS Service. diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/AudioConfig.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/AudioConfig.java similarity index 98% rename from bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/AudioConfig.java rename to bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/AudioConfig.java index b627d21609850..94432140de0b8 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/AudioConfig.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/AudioConfig.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.voice.googletts.internal.protocol; +package org.openhab.voice.googletts.internal.dto; /** * The configuration of the synthesized audio. diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/AudioEncoding.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/AudioEncoding.java similarity index 95% rename from bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/AudioEncoding.java rename to bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/AudioEncoding.java index e3bf11778d3c2..01031324114f2 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/AudioEncoding.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/AudioEncoding.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.voice.googletts.internal.protocol; +package org.openhab.voice.googletts.internal.dto; /** * Configuration to set up audio encoder. diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/ListVoicesResponse.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/ListVoicesResponse.java similarity index 94% rename from bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/ListVoicesResponse.java rename to bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/ListVoicesResponse.java index 36ada3160e167..352873ae51e1a 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/ListVoicesResponse.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/ListVoicesResponse.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.voice.googletts.internal.protocol; +package org.openhab.voice.googletts.internal.dto; import java.util.List; diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/SsmlVoiceGender.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/SsmlVoiceGender.java similarity index 95% rename from bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/SsmlVoiceGender.java rename to bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/SsmlVoiceGender.java index 36590e970c086..c1322c046687c 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/SsmlVoiceGender.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/SsmlVoiceGender.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.voice.googletts.internal.protocol; +package org.openhab.voice.googletts.internal.dto; /** * Gender of the voice as described in SSML voice element. diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/SynthesisInput.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/SynthesisInput.java similarity index 96% rename from bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/SynthesisInput.java rename to bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/SynthesisInput.java index 104233eb6a611..e92f68343aba3 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/SynthesisInput.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/SynthesisInput.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.voice.googletts.internal.protocol; +package org.openhab.voice.googletts.internal.dto; /** * Contains text input to be synthesized. Either text or ssml must be supplied. Supplying both or neither returns diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/SynthesizeSpeechRequest.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/SynthesizeSpeechRequest.java similarity index 96% rename from bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/SynthesizeSpeechRequest.java rename to bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/SynthesizeSpeechRequest.java index e0df9d0c1965e..0a397eedb6663 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/SynthesizeSpeechRequest.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/SynthesizeSpeechRequest.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.voice.googletts.internal.protocol; +package org.openhab.voice.googletts.internal.dto; /** * Synthesizes speech synchronously: receive results after all text input has been processed. diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/SynthesizeSpeechResponse.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/SynthesizeSpeechResponse.java similarity index 95% rename from bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/SynthesizeSpeechResponse.java rename to bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/SynthesizeSpeechResponse.java index e1d62159d1a61..f3835adf81a74 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/SynthesizeSpeechResponse.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/SynthesizeSpeechResponse.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.voice.googletts.internal.protocol; +package org.openhab.voice.googletts.internal.dto; /** * The message returned to the client by the text.synthesize method. diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/Voice.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/Voice.java similarity index 96% rename from bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/Voice.java rename to bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/Voice.java index aad921d4d2c55..456e19ccc6149 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/Voice.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/Voice.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.voice.googletts.internal.protocol; +package org.openhab.voice.googletts.internal.dto; import java.util.List; diff --git a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/VoiceSelectionParams.java b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/VoiceSelectionParams.java similarity index 98% rename from bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/VoiceSelectionParams.java rename to bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/VoiceSelectionParams.java index f0d7d499854fb..bf9107eb8ce5e 100644 --- a/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/protocol/VoiceSelectionParams.java +++ b/bundles/org.openhab.voice.googletts/src/main/java/org/openhab/voice/googletts/internal/dto/VoiceSelectionParams.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.voice.googletts.internal.protocol; +package org.openhab.voice.googletts.internal.dto; /** * Description of which voice to use for a synthesis request.