File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed
core/com.intellijava.core/src
main/java/com/intellijava/core
test/java/com/intellijava/core Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change 44import java .util .HashMap ;
55import java .util .List ;
66import java .util .Map ;
7-
87import com .intellijava .core .model .AudioResponse ;
98import com .intellijava .core .model .SpeechModels ;
109import com .intellijava .core .model .input .SpeechInput ;
Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ private SpeechInput(Builder builder) {
1010 this .gender = builder .gender ;
1111 }
1212
13+ public SpeechInput (String text , Gender gender ) {
14+ this .text = text ;
15+ this .gender = gender ;
16+ }
17+
1318 public static class Builder {
1419
1520 private String text ;
@@ -42,7 +47,17 @@ public Gender getGender() {
4247 return gender ;
4348 }
4449
45- public enum Gender {
50+ public void setText (String text ) {
51+ this .text = text ;
52+ }
53+
54+ public void setGender (Gender gender ) {
55+ this .gender = gender ;
56+ }
57+
58+
59+
60+ public enum Gender {
4661 MALE , FEMALE ;
4762 }
4863}
Original file line number Diff line number Diff line change 88
99import org .junit .Test ;
1010
11+ import com .intellijava .core .controller .RemoteSpeechModel ;
1112import com .intellijava .core .model .AudioResponse ;
13+ import com .intellijava .core .model .SpeechModels ;
14+ import com .intellijava .core .model .input .SpeechInput ;
15+ import com .intellijava .core .model .input .SpeechInput .Gender ;
1216import com .intellijava .core .utils .AudioHelper ;
1317import com .intellijava .core .utils .Config2 ;
1418import com .intellijava .core .wrappers .GoogleAIWrapper ;
@@ -76,4 +80,24 @@ public void testText2FemaleSpeechWrapper() {
7680 }
7781 }
7882 }
83+
84+ @ Test
85+ public void testText2FemaleRemoteSpeecModel () {
86+ SpeechInput input = new SpeechInput .Builder ("Hi, I am Intelligent Java." ).
87+ setGender (Gender .FEMALE ).build ();
88+
89+ RemoteSpeechModel model = new RemoteSpeechModel (apiKey , SpeechModels .google );
90+
91+ try {
92+ byte [] decodedAudio = model .generateEnglishText (input );
93+ assert AudioHelper .saveTempAudio (decodedAudio ) == true ;
94+ AudioHelper .deleteTempAudio ();
95+ } catch (IOException e ) {
96+ if (apiKey .isBlank ()) {
97+ System .out .print ("testRemoteSpeech set the API key to run the test case." );
98+ } else {
99+ fail ("testRemoteSpeech failed with exception: " + e .getMessage ());
100+ }
101+ }
102+ }
79103}
You can’t perform that action at this time.
0 commit comments