首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用MaryTTS时更改音频速度

使用MaryTTS时更改音频速度
EN

Stack Overflow用户
提问于 2020-04-06 23:07:25
回答 1查看 193关注 0票数 0

我正在尝试使用marytts进行文本到语音的转换。它可以工作,但我不知道如何改变速度。我希望它可以读得快或慢。下面是我的代码:

代码语言:javascript
复制
public void playEmail(String sender, String subject, String content, Integer voiceType, Float speed) throws MaryConfigurationException, SynthesisException, InterruptedException {
        MaryInterface maryTts = new LocalMaryInterface();
        Set<String> voices = maryTts.getAvailableVoices();
        ArrayList<String> voice=new ArrayList<>(voices);
        //voice 0:male 1:female 2:robot
        if(voiceType==0||voiceType==1||voiceType==2){
            maryTts.setVoice(voice.get(voiceType));
        }
        else{
            maryTts.setVoice(voice.get(0));
            System.out.println("Wrong voice type number!");
        }
        //read subject
        AudioInputStream audioSubject = maryTts.generateAudio("The subject of this email is"+subject);
        AudioPlayer playerSubject = new AudioPlayer(audioSubject);
        playerSubject.start();
        playerSubject.join();
        //read content
        AudioInputStream audioContent = maryTts.generateAudio(content);
        AudioPlayer playerContent = new AudioPlayer(audioContent);
        playerContent.start();
        playerContent.join();
    }

    public static void main(String[] args) throws InterruptedException, MaryConfigurationException, SynthesisException {
        String content="Individuals with very busy schedules sometimes find it difficult to catch up on emails. " +
                "It is estimated that the average worker spends more than 11 hours a week on emails. " +
                "This number of hours increases with senior executives or very busy individuals and as such, " +
                "they miss important emails and deadlines, hire an executive assistant or look for other creative ways to fix this problem. " +
                "MyAudioEmailr, is an application that attempts to fix this problem by converting a user’s text email into speech. " +
                "Essentially, the application should work as a regular email client that allows users to read and send emails but in addition, " +
                "the application should be able to read the emails to the user, using a chosen voice. The application can be developed as windows or mobile application.";
        AudioServiceImpl test =new AudioServiceImpl();
        test.playEmail("daxi","Test",content,0,1.0f);
    }

}

有人能告诉我怎么做吗?谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-07 23:51:35

代码语言:javascript
复制
maryTts.setAudioEffects("Rate(durScale:1.5)");

添加这个,它就会起作用。在测试0.5是快速之后,1.0是正常的,而1.5是缓慢的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61062866

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档