Изменить скорость звука при использовании MaryTTS - PullRequest
0 голосов
/ 06 апреля 2020

Я пытаюсь использовать 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);
    }

}

Может кто-нибудь сказать мне, как это сделать? Спасибо!

1 Ответ

0 голосов
/ 07 апреля 2020
maryTts.setAudioEffects("Rate(durScale:1.5)");

Добавьте это, тогда это будет работать. После теста 0,5 быстро 1,0 нормально, а 1,5 медленно.

...