Super simple Java text-to-speech!-3 lines of code to directly export voice data

This time we need to use Java19 JDK, we need to download the Colorful basic framework

Click to download - > [Click here to download Colorful multi-module basic library]

It will tell you brief information about Colorful,

Provides rich APIs and modules - the above Java speech-to-text is a plug-in of this framework

Install and start

Table of contents

Install and start

Download tutorial:

decompress

Import plugin

use

        Basic usage:

1.0 method introduction

Example        

change speaking speed

change sound volume

end


Download tutorial:

        Click the following link to enter github/CSDM resources (free) download: CSDN resources / Github

decompress

        Unzip to any location (demo)

    Here I unzip it directly to the project root directory

Import plugin

Import JNAudio.dll plug-in


use

        Basic usage:

        //引入插件
        System.load(System.getProperty("user.dir")+"/colorful_Plugins_include/JNAudio.dll");
        //创造一个JNAudio插件需先引入JNAudio.dll
        JNAudio c =new JNAudio();
        //绑定Java实例类
        c.initModel();
        //文字转语音
        c.speechUp("欢迎使用Colorful基本框架-JNAudio插件");
        //释放绑定
        c.closeAudio();

1.0 method introduction

        

initModel
Bind the Java instantiation class ID to the Dll object. Each binding only needs to be used once. This will cause the plug-in library to generate a separate DLL object and bind the Java class you instantiated this time. It can be used separately under multi-threading. When used, the object needs to be exited at the end, and the plug-in library will automatically recycle 
* (it will be re-instantiated when you release it using initModel/InitModel.
InitModel
The difference from initModel is that this is the second instance before the dll is bound to the Java instance class, which can change the default text of the dll object. 
Parameters: String sa-text-to-speech content
tryAgain
Re-instantiate the DLL but the Java does not change and can be used if it is already bound
speechUp
Convert text to PCM voice and play it directly (text to speech). At the end, the content garbage will be automatically recycled. 
Parameter: sa voice content
speech_end
Release last text-to-speech
speech_parser
pause voice speech
speech_continual
Resume paused speech
speech_spb_output
Bind the text-to-speech data format to WAV and bind it to a local file. You need to pay attention to whether your program has sufficient permissions. The 
parameter is the file path bound to JNAudio 
and the parameter is the voice bound this time.
get_speech_size
Get the sound effect size of JNAudio 
return int
get_speech_rate
Get the speed of sound of JNAudio 
return int
updateAudioText
Update default speech-to-text content
updateAudioRate
Change the sound speed of JNAudio
updateAudioSize
Change the sound effect size of JNAudio
closeAudio
Release the Java object and the bound dll object. If you release it, you will not be able to call JNAudio and you need to use initModel/InitModel to rebind.

Example        

         

        //引入插件
        System.load(System.getProperty("user.dir")+"/colorful_Plugins_include/JNAudio.dll");
        //创造一个JNAudio插件需先引入JNAudio.dll
        JNAudio c =new JNAudio();
        //绑定Java实例类
        c.initModel();
        //文字转语音
        c.speechUp("即将开始-欢迎使用Colorful基本框架-JNAudio插件");
        //默认无声导出文字转语音数据
        c.speech_spb_output("1.wav","欢迎使用Colorful基本框架-JNAudio插件");
        //释放绑定
        c.closeAudio();

change speaking speed

        //引入插件
        System.load(System.getProperty("user.dir")+"/colorful_Plugins_include/JNAudio.dll");
        //创造一个JNAudio插件需先引入JNAudio.dll
        JNAudio c =new JNAudio();
        //绑定Java实例类
        c.initModel();
        //改变音频速率
        c.updateAudioRate(8);
        //文字转语音
        c.speechUp("即将开始-欢迎使用Colorful基本框架-JNAudio插件");
        //释放绑定
        c.closeAudio();

change sound volume

        //引入插件
        System.load(System.getProperty("user.dir")+"/colorful_Plugins_include/JNAudio.dll");
        //创造一个JNAudio插件需先引入JNAudio.dll
        JNAudio c =new JNAudio();
        //绑定Java实例类
        c.initModel();
        //改变音频速率
        c.updateAudioSize(100);
        //文字转语音
        c.speechUp("即将开始-欢迎使用Colorful基本框架-JNAudio插件");
        //释放绑定
        c.closeAudio();

end

Guess you like

Origin blog.csdn.net/m0_61267721/article/details/132729846