嘿,我在 Java 中制作程序,如果您在控制台中输入,然后它会响应计算机实际说话(有声音),我使用的是 FreeTTs 语音合成器。出于某种原因,当我编写以下代码时,它的输出不是我想要的。
import java.util.Scanner;
import com.sun.speech.freetts.VoiceManager;
import com.sun.speech.freetts.Voice;
public class TextToSpeech {
public static void main(String args[]){
Scanner input = new Scanner(System.in);
String userInput = input.nextLine();
if(userInput == "hi"){
Voice v;
VoiceManager vm=VoiceManager.getInstance();
v=vm.getVoice("kevin16");
v.allocate();
v.speak("Hey my name is jarvis");
input.close();
}else
System.out.println("you suck try again");
}
}