Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🙊 Speech Recognition , Text To Speech , Google Translate

License

NotificationsYou must be signed in to change notification settings

safer-bot/goxr3plus_java-google-speech-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ko-fi

THIS LIBRARY IS NOT SUPPORTED BY ME ACTIVELY ANYMORE , feel free to contribute :)


Java Google Speech Api ( Library )

🎤

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.


Latest VersionGitHub contributorsHitCountTotal Downloads

Google has released it's official library forGoogle Speech Recognition . Check this issue for Official Google Speech Library code solution ->#4

Add it to your project using JitPack :

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>

Java Google Speech API

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 :)

Description

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.

Features

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 text
Keep in mind that:

It doesn't currently support the new officialGoogle Cloud Speech API(which is also free but for a certain amount of words)

Update 2/7/2018

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 AccountGenerate Speech Recognition Private API Keys
FirstSecond

2) Google translate full support throughGoogleTranslate.java

- A translator using Google Translate (courtesy of Skylion's Google Toolkit)
Tutorial 1Tutorial 2
FirstSecond

3) Text to Speech , Audio Synthesizer throughSynthesiserV2.java

- Retrieves synthesized text in an InputStream (MP3 data ready to be played)
Tutorial 1Tutorial 2
FirstSecond

The program supports dozens of languages and even has the ability to auto-detect languages!

Maven Build

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java100.0%

[8]ページ先頭

©2009-2025 Movatter.jp