###前提・実現したいこと
今、java ttsに取り組んでいます。文字を音声にして読み上げる機能です。実行環境はeclipseです。
###発生している問題・エラーメッセージ
The method speakPlainText(String, null) is undefined for the type SoftSynthesizer
###該当のソースコード
import javax.speech.EngineList; import com.sun.media.sound.SoftSynthesizer; import com.sun.speech.freetts.jsapi.FreeTTSEngineCentral; import java.util.Locale; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import javax.speech.*; import javax.speech.synthesis.*; import java.util.Locale; //import javax.speech.synthesis.SynthesizerMode; //import javax.speech.synthesis.SynthesizerModeDesc; //import javax.speech.synthesis.*; //import javax.speech.synthesis.Synthesizer; public class W60xTts1 { public static void main (String args[]) { try { while (true) { String text; BufferedReader reader = new BufferedReader (new InputStreamReader(System.in)); //System.out.print("Enter time (HH:MM): "); System.out.print("Enter text: "); System.out.flush(); text = reader.readLine(); if ((text == null) || (text.length() == 0)) { break; } else { timeToSpeech(text); } } } catch (IOException ioe) { ioe.printStackTrace(); } } public static void timeToSpeech(String text) { //String theTime = TimeUtils.timeToString(time); //if (theTime != null) { if (text != null) { SoftSynthesizer.speakPlainText(text, null); } else { // throw new IllegalArgumentException("Bad time format"); //System.out.println("Bad time format. The format should be HH:MM"); System.out.println("Text is empty."); } } ```###試したこと jarを一通りは追加したのですがいまだにエラーが表示されます。 SoftSynthesizer.speakPlainText(text, null); のspeakPlainTextの部分にエラーメッセージが出てきます。あとそれさえ直せばコンパイルできるはずです。
コードをマークダウンして下さい。コード部分を選択して<code>というボタンを押すとコードが読みやすくなります。
回答3件
あなたの回答
tips
プレビュー