1414import simplexity .config .config .AwsConfig ;
1515import simplexity .config .config .ReplaceTextConfig ;
1616import simplexity .config .config .TTSConfig ;
17- import simplexity .messages . Errors ;
18- import simplexity .util .Util ;
17+ import simplexity .config . locale . Message ;
18+ import simplexity .util .Logging ;
1919
2020import java .io .InputStream ;
2121
@@ -25,7 +25,7 @@ public class SpeechHandler {
2525
2626 public SpeechHandler () {
2727 this .voiceId = AwsConfig .getInstance ().getDefaultVoice ();
28- Util .log (logger , "Initialized SpeechHandler with default voice: " + voiceId .toString (), Level .INFO );
28+ Logging .log (logger , "Initialized SpeechHandler with default voice: " + voiceId .toString (), Level .INFO );
2929 }
3030
3131 /**
@@ -45,7 +45,7 @@ public void processSpeech(String text) {
4545 speechStream = synthesizeSpeech (processedText , voiceId );
4646 }
4747 if (speechStream == null ) {
48- Util .logAndPrint (logger , Errors . CAUGHT_EXCEPTION .replace ("%error%" , "Speech stream is null" ), Level .ERROR );
48+ Logging .logAndPrint (logger , Message . GENERAL_ERROR . getMessage () .replace ("%error%" , "Speech stream is null" ), Level .ERROR );
4949 return ;
5050 }
5151
@@ -58,7 +58,6 @@ public void processSpeech(String text) {
5858 */
5959
6060 public String replaceText (String text ) {
61- TTSConfig ttsConfig = TTSConfig .getInstance ();
6261 for (String key : ReplaceTextConfig .getInstance ().getReplaceText ().keySet ()) {
6362 text = text .replace (key , ReplaceTextConfig .getInstance ().getReplaceText ().get (key ));
6463 }
@@ -103,23 +102,22 @@ public InputStream synthesizeSpeech(String text, VoiceId voice) {
103102
104103 /**
105104 * Plays the text as speech
106- *
107105 */
108106 public void playSpeech (InputStream speechStream ) {
109107 AdvancedPlayer player ;
110108 try {
111109 player = new AdvancedPlayer (speechStream , FactoryRegistry .systemRegistry ().createAudioDevice ());
112110 player .play ();
113111 } catch (Exception exception ) {
114- Util .logAndPrint (logger , Errors . CAUGHT_EXCEPTION .replace ("%error%" , exception .getMessage ()), Level .ERROR );
112+ Logging .logAndPrint (logger , Message . GENERAL_ERROR . getMessage () .replace ("%error%" , exception .getMessage ()), Level .ERROR );
115113 }
116114 }
117115
118116 /**
119117 * Logs errors during speech synthesis.
120118 */
121119 private void logSynthesisError (Exception e , String text ) {
122- Util .logAndPrint (logger , Errors . CAUGHT_EXCEPTION .replace ("%error%" , e .getMessage ()), Level .ERROR );
123- Util .logAndPrint (logger , Errors .MESSAGE_NOT_PARSABLE .replace ("%message%" , text ), Level .ERROR );
120+ Logging .logAndPrint (logger , Message . GENERAL_ERROR . getMessage () .replace ("%error%" , e .getMessage ()), Level .ERROR );
121+ Logging .logAndPrint (logger , Message .MESSAGE_NOT_PARSABLE . getMessage () .replace ("%message%" , text ), Level .ERROR );
124122 }
125123}
0 commit comments