当我们使用Java语音API时如何定义mbrola.base属性?

发布于 2024-09-12 06:58:18 字数 1835 浏览 6 评论 0原文

import javax.speech.EngineList;
import javax.speech.EngineCreate;
import javax.speech.synthesis.SynthesizerModeDesc;
import javax.speech.synthesis.Synthesizer;
import com.sun.speech.freetts.jsapi.FreeTTSEngineCentral;
import java.util.Locale;

public class HelloWorld {
    public static void main(String args[]) {

        try {
            // create SynthesizerModeDesc that will match the FreeTTS Synthesizer
            SynthesizerModeDesc modeDesc = new SynthesizerModeDesc(
                    null, 
                    "general", /* use "time" or "general" */
                    Locale.US, 
                    Boolean.FALSE,
                    null);
            if(modeDesc == null)
                System.out.println("Error creating mode descriptor");

            FreeTTSEngineCentral central = new FreeTTSEngineCentral();
            Synthesizer synthesizer = null;

            EngineList list = central.createEngineList(modeDesc);
            if (list.size() > 0) { 
                EngineCreate creator = (EngineCreate) list.get(0); 
                synthesizer = (Synthesizer) creator.createEngine(); 
            }

            if (synthesizer == null) {
                System.err.println("Cannot create synthesizer");
                System.exit(1);
            }
            //get ready to speak
            synthesizer.allocate();
            synthesizer.resume();

            // say hello world
            synthesizer.speakPlainText("Hello, world!", null);
            // wait until speaking is done and clean up
            synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY);
            synthesizer.deallocate();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}  

它向我展示了诸如“系统属性“mbrola.base”未定义。不会使用 MBROLA 声音”之类的内容。那我该怎么办呢? 我听不到任何东西。

import javax.speech.EngineList;
import javax.speech.EngineCreate;
import javax.speech.synthesis.SynthesizerModeDesc;
import javax.speech.synthesis.Synthesizer;
import com.sun.speech.freetts.jsapi.FreeTTSEngineCentral;
import java.util.Locale;

public class HelloWorld {
    public static void main(String args[]) {

        try {
            // create SynthesizerModeDesc that will match the FreeTTS Synthesizer
            SynthesizerModeDesc modeDesc = new SynthesizerModeDesc(
                    null, 
                    "general", /* use "time" or "general" */
                    Locale.US, 
                    Boolean.FALSE,
                    null);
            if(modeDesc == null)
                System.out.println("Error creating mode descriptor");

            FreeTTSEngineCentral central = new FreeTTSEngineCentral();
            Synthesizer synthesizer = null;

            EngineList list = central.createEngineList(modeDesc);
            if (list.size() > 0) { 
                EngineCreate creator = (EngineCreate) list.get(0); 
                synthesizer = (Synthesizer) creator.createEngine(); 
            }

            if (synthesizer == null) {
                System.err.println("Cannot create synthesizer");
                System.exit(1);
            }
            //get ready to speak
            synthesizer.allocate();
            synthesizer.resume();

            // say hello world
            synthesizer.speakPlainText("Hello, world!", null);
            // wait until speaking is done and clean up
            synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY);
            synthesizer.deallocate();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}  

It's showing me the thing like "System property "mbrola.base" is undefined. Will not use MBROLA voices." So what should I do?
I am not able to Listen any thing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梅窗月明清似水 2024-09-19 06:58:18

将 voice.properties 文件复制到“java.home”或“user.home”

Copy speech.properties file into "java.home" or "user.home"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文