Java speech api примеры

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

The J.A.R.V.I.S. Speech API is designed to be simple and efficient, using the speech engines created by Google to provide functionality for parts of the API. Essentially, it is an API written in Java, including a recognizer, synthesizer, and a microphone capture utility. The project uses Google services for the synthesizer and recognizer. While …

License

lkuza2/java-speech-api

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Читайте также:  Javascript прервать выполнение кода

Latest commit

Fix OpenJDK 9 dependency and compiler versioning

Git stats

Files

Failed to load latest commit information.

README.markdown

J.A.R.V.I.S. Java Speech API: Just A Reliable Vocal Interpreter & Synthesizer. This is a project for the Java Speech API. The program interprets vocal inputs into text and synthesizes voices from text input. The program supports dozens of languages and even has the ability to auto-detect languages!

The J.A.R.V.I.S. Speech API is designed to be simple and efficient, using the speech engines created by Google to provide functionality for parts of the API. Essentially, it is an API written in Java, including a recognizer, synthesizer, and a microphone capture utility. The project uses Google services for the synthesizer and recognizer. While this requires an Internet connection, it provides a complete, modern, and fully functional speech API in Java.

The API currently provides the following functionality,

  • Microphone Capture API (Wrapped around the current Java API for simplicity)
  • A speech recognizer using Google’s recognizer service
    • Converts WAVE files from microphone input to FLAC (using existing API, see CREDITS)
    • Retrieves Response from Google, including confidence score and text
    • Retrieves synthesized text in an InputStream (MP3 data ready to be played)

    To get access to the Google API, you need an API key. To get this, you need to follow the instructions here:

    A sample application using this library can be found here:

    See CHANGELOG.markdown for Version History/Changelog

    See CREDITS.markdown for Credits

    Источник

    Text To Speech using Java-Swing and Java Speech API

    Hi, Today we are learning how to develop a text-to-speech application in Java. In this project, we are using Java-Swing and Java Speech API to develop this application.

    Java-Swing is a lightweight and cross-platform toolkit that provides the graphical user interface(GUI) to java programs. Java Speech API is an application programming interface that provides features to develop cross-platform voice applications.

    To develop this project we require to download FreeTTS(An open-source implementation of Java Speech API).

    Download the Zip folder of FreeTTS from here. Extract file and open lib folder in it then run jsapi.exe if you are using windows or use jsapi.sh if you are using mac/Linux. After executing the jsapi file it will generate jsapi.jar.

    Now we have to create a new java project in any IDE and name it TextToSpeech. Next, create a class file and name it TextToSpeech.

    Now we have to add some jar files in this project from the freetts folder the path and list of the jar files are listed below.

    After including all these jar file we have to program the TextToSpeech.java file just copy the given below code and paste it in that file.

    import com.sun.speech.freetts.Voice; import com.sun.speech.freetts.VoiceManager; public class TextToSpeech < public void Speak(String text) < System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory"); Voice textaudio; textaudio = VoiceManager.getInstance().getVoice("kevin16"); if (textaudio != null) < textaudio.allocate(); >try < textaudio.setRate(150); textaudio.setPitch(150); textaudio.setVolume(6); textaudio.speak(text); >catch (Exception e) < e.printStackTrace(); >> >

    Now create a Java swing application and name it TextGui and copy the given code and paste it into that file.

    import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.JLabel; import javax.swing.SwingConstants; import java.awt.Font; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.JEditorPane; public class TextGui < private JFrame frame; /** * Launch the application. */ public static void main(String[] args) < EventQueue.invokeLater(new Runnable() < public void run() < try < TextGui window = new TextGui(); window.frame.setVisible(true); >catch (Exception e) < e.printStackTrace(); >> >); > /** * Create the application. */ public TextGui() < initialize(); >/** * Initialize the contents of the frame. */ private void initialize() < frame = new JFrame(); frame.setBounds(100, 100, 512, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JLabel lblTextToSpeech = new JLabel("Text To Speech"); lblTextToSpeech.setFont(new Font("Dialog", Font.BOLD, 20)); lblTextToSpeech.setHorizontalAlignment(SwingConstants.CENTER); lblTextToSpeech.setBounds(147, 12, 216, 33); frame.getContentPane().add(lblTextToSpeech); JLabel lblEnterTheText = new JLabel("Enter The Text Please"); lblEnterTheText.setBounds(12, 85, 165, 33); frame.getContentPane().add(lblEnterTheText); JEditorPane editorPane = new JEditorPane(); editorPane.setBounds(190, 85, 296, 99); frame.getContentPane().add(editorPane); JButton btnSpeak = new JButton("Speak"); btnSpeak.addActionListener(new ActionListener() < public void actionPerformed(ActionEvent arg0) < TextToSpeech t=new TextToSpeech(); t.Speak(editorPane.getText()); >>); btnSpeak.setBounds(195, 211, 117, 25); frame.getContentPane().add(btnSpeak); > >

    Now run this project and build your own Text To Speech Application.

    Note: If you are facing some errors while executing this project then follow the given below steps.

    • Create a new project Text2Speech(use JDK grater than or equal to JDK-11).
    • Next, Create a new Swing Application and name it text2speech.
    • Now download a zip folder from here unzip it.
    • Now open this folder and you will find TextToSpeech.jar file
    • Now include this jar file in the project.
    • Now copy the give below code and paste it inside that file.
    import java.awt.EventQueue; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingConstants; import com.txt.TextToSpeech; public class text2speech < private JFrame frame; /** * Launch the application. */ public static void main(String[] args) < EventQueue.invokeLater(new Runnable() < public void run() < try < text2speech window = new text2speech(); window.frame.setVisible(true); >catch (Exception e) < e.printStackTrace(); >> >); > /** * Create the application. */ public text2speech() < initialize(); >/** * Initialize the contents of the frame. */ private void initialize() < frame = new JFrame(); frame.setBounds(100, 100, 512, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JLabel lblTextToSpeech = new JLabel("Text To Speech"); lblTextToSpeech.setFont(new Font("Dialog", Font.BOLD, 20)); lblTextToSpeech.setHorizontalAlignment(SwingConstants.CENTER); lblTextToSpeech.setBounds(147, 12, 216, 33); frame.getContentPane().add(lblTextToSpeech); JLabel lblEnterTheText = new JLabel("Enter The Text Please"); lblEnterTheText.setBounds(12, 85, 165, 33); frame.getContentPane().add(lblEnterTheText); JEditorPane editorPane = new JEditorPane(); editorPane.setBounds(190, 85, 296, 99); frame.getContentPane().add(editorPane); JButton btnSpeak = new JButton("Speak"); btnSpeak.addActionListener(new ActionListener() < public void actionPerformed(ActionEvent arg0) < TextToSpeech t=new TextToSpeech(); t.Speak(editorPane.getText()); >>); btnSpeak.setBounds(195, 211, 117, 25); frame.getContentPane().add(btnSpeak); > >

    Thank you for reading this blog.

    Источник

Оцените статью