Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork35
🙊 Speech Recognition , Text To Speech , Google Translate
License
goxr3plus/java-google-speech-api
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
THIS LIBRARY IS NOT SUPPORTED BY ME ACTIVELY ANYMORE , feel free to contribute :)
🎤
This project 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.
Google has released it's official library forGoogle Speech Recognition . Check this issue for Official Google Speech Library code solution ->#4
https://jitpack.io/private#goxr3plus/java-google-speech-api
Step 1. Add the JitPack repository to your build file
<repositories><repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository></repositories>
Step 2. Add the dependency
<dependency> <groupId>com.github.goxr3plus</groupId> <artifactId>java-google-speech-api</artifactId> <version>8.0.0</version> </dependency>
Warning : The default secret key i was using is not working anymore (because ... i have to pay lol ) , you have to make your own , check tutorials :)
This project 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.
This project is separated on 3 parts :
1) Google Speech Recognition based on Chromium Speech API (which is free with restrictions for commercial applications) throughGSpeechDuplex.java
- Microphone Capture API is used (Wrapped around the current Java API for simplicity) - Converts WAVE files from microphone input to FLAC (using existing API, see CREDITS) - Retrieves Response from Google, including confidence score and textIt doesn't currently support the new officialGoogle Cloud Speech API(which is also free but for a certain amount of words)
Check this issue for Official Google Speech Library code solution ->#4
The new Google Cloud Speech API is not supported yet but you can seehere the official Alpha Library from supported by Google
| Create Google Cloud Account | Generate Speech Recognition Private API Keys |
|---|---|
![]() | ![]() |
2) Google translate full support throughGoogleTranslate.java
- A translator using Google Translate (courtesy of Skylion's Google Toolkit)| Tutorial 1 | Tutorial 2 |
|---|---|
![]() | ![]() |
3) Text to Speech , Audio Synthesizer throughSynthesiserV2.java
- Retrieves synthesized text in an InputStream (MP3 data ready to be played)| Tutorial 1 | Tutorial 2 |
|---|---|
![]() | ![]() |
The program supports dozens of languages and even has the ability to auto-detect languages!
Maven Clean Package [ With Javadocs produced ]
mvn clean package
Maven Clean Package [ No Javadocs produced ]
mvn -Dmaven.javadoc.skip=true clean package
Java Swing speech recognition example usingGSpeechDuplex.java
packageTry_Google_Speech_Recognition_Simple;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.io.IOException;importjavax.swing.BoxLayout;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;importjavax.swing.JScrollPane;importjavax.swing.JTextArea;importcom.darkprograms.speech.microphone.Microphone;importcom.darkprograms.speech.recognizer.GSpeechDuplex;importcom.darkprograms.speech.recognizer.GSpeechResponseListener;importcom.darkprograms.speech.recognizer.GoogleResponse;importnet.sourceforge.javaflacencoder.FLACFileWriter;publicclassTryGoogleSpeechRecognitionSimpleimplementsGSpeechResponseListener {publicstaticvoidmain(String[]args)throwsIOException {finalMicrophonemic =newMicrophone(FLACFileWriter.FLAC);// You have to make your own GOOGLE_API_KEYGSpeechDuplexduplex =newGSpeechDuplex("GOOGLE_API_KEY");duplex.setLanguage("en");JFrameframe =newJFrame("Jarvis Speech API DEMO");frame.setDefaultCloseOperation(3);JTextArearesponse =newJTextArea();response.setEditable(false);response.setWrapStyleWord(true);response.setLineWrap(true);finalJButtonrecord =newJButton("Record");finalJButtonstop =newJButton("Stop");stop.setEnabled(false);record.addActionListener(newActionListener() {publicvoidactionPerformed(ActionEventevt) {newThread(() -> {try {duplex.recognize(mic.getTargetDataLine(),mic.getAudioFormat());}catch (Exceptionex) {ex.printStackTrace();}}).start();record.setEnabled(false);stop.setEnabled(true);}});stop.addActionListener(newActionListener() {publicvoidactionPerformed(ActionEventarg0) {mic.close();duplex.stopSpeechRecognition();record.setEnabled(true);stop.setEnabled(false);}});JLabelinfoText =newJLabel("<html><div style=\"text-align: center;\">Just hit record and watch your voice be translated into text.\n<br>Only English is supported by this demo, but the full API supports dozens of languages.<center></html>",0);frame.getContentPane().add(infoText);infoText.setAlignmentX(0.5F);JScrollPanescroll =newJScrollPane(response);frame.getContentPane().setLayout(newBoxLayout(frame.getContentPane(),1));frame.getContentPane().add(scroll);JPanelrecordBar =newJPanel();frame.getContentPane().add(recordBar);recordBar.setLayout(newBoxLayout(recordBar,0));recordBar.add(record);recordBar.add(stop);frame.setVisible(true);frame.pack();frame.setSize(500,500);frame.setLocationRelativeTo(null);duplex.addResponseListener(newGSpeechResponseListener() {Stringold_text ="";publicvoidonResponse(GoogleResponsegr) {Stringoutput ="";output =gr.getResponse();if (gr.getResponse() ==null) {this.old_text =response.getText();if (this.old_text.contains("(")) {this.old_text =this.old_text.substring(0,this.old_text.indexOf('('));}System.out.println("Paragraph Line Added");this.old_text = (response.getText() +"\n" );this.old_text =this.old_text.replace(")","").replace("( ","");response.setText(this.old_text);return;}if (output.contains("(")) {output =output.substring(0,output.indexOf('('));}if (!gr.getOtherPossibleResponses().isEmpty()) {output =output +" (" + (String)gr.getOtherPossibleResponses().get(0) +")";}System.out.println(output);response.setText("");response.append(this.old_text);response.append(output);}});}@OverridepublicvoidonResponse(GoogleResponseparamGoogleResponse) {// TODO Auto-generated method stub}}
About
🙊 Speech Recognition , Text To Speech , Google Translate
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.





