更改MaryTTS使用时的音频速度

huangapple go评论74阅读模式
英文:

Change audio speed when using MaryTTS

问题

以下是翻译好的部分:

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);
    }
}

希望这对你有所帮助!如果有其他翻译需求,请随时提问。

英文:

I am trying to use marytts to do text to speech. It works but I don't know how to change the speed. I want it can be read fast or slow. Here is my code:

public void playEmail(String sender, String subject, String content, Integer voiceType, Float speed) throws MaryConfigurationException, SynthesisException, InterruptedException {
MaryInterface maryTts = new LocalMaryInterface();
Set&lt;String&gt; voices = maryTts.getAvailableVoices();
ArrayList&lt;String&gt; voice=new ArrayList&lt;&gt;(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(&quot;Wrong voice type number!&quot;);
}
//read subject
AudioInputStream audioSubject = maryTts.generateAudio(&quot;The subject of this email is&quot;+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=&quot;Individuals with very busy schedules sometimes find it difficult to catch up on emails. &quot; +
&quot;It is estimated that the average worker spends more than 11 hours a week on emails. &quot; +
&quot;This number of hours increases with senior executives or very busy individuals and as such, &quot; +
&quot;they miss important emails and deadlines, hire an executive assistant or look for other creative ways to fix this problem. &quot; +
&quot;MyAudioEmailr, is an application that attempts to fix this problem by converting a user’s text email into speech. &quot; +
&quot;Essentially, the application should work as a regular email client that allows users to read and send emails but in addition, &quot; +
&quot;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.&quot;;
AudioServiceImpl test =new AudioServiceImpl();
test.playEmail(&quot;daxi&quot;,&quot;Test&quot;,content,0,1.0f);
}
}

Can anybody tell me how to do that? Thanks!

答案1

得分: 0

maryTts.setAudioEffects("Rate(durScale:1.5)");
Add this then it will work. After test 0.5 is fast 1.0 is normal and 1.5 is slow.

英文:
maryTts.setAudioEffects(&quot;Rate(durScale:1.5)&quot;);

Add this then it will work. After test 0.5 is fast 1.0 is normal and 1.5 is slow.

huangapple
  • 本文由 发表于 2020年4月6日 23:07:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/61062866.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定