Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finished write on down stream... Error #1

Open
LarsZocher opened this issue Sep 22, 2017 · 20 comments
Open

Finished write on down stream... Error #1

LarsZocher opened this issue Sep 22, 2017 · 20 comments

Comments

@LarsZocher
Copy link

Hello,
I try to make a bot like the "Alexa" from Amazon for my school project, and i found you on youtube...
So, my problem is, that I want, that my Alexa is listening "forever", but when I say nothing for a while, my program say's: "Finished write on down stream..." in the console. I tried to make the google speech to text as a thread, and i restart the theard every 20 seconds, but it doesn't work. But this time with the theard, it writes "Finished write on down stream..." 10 times at the same time in the chat.

I hope you can fix it, thanks

// https://pastebin.com/WY5izrkb <-- my code
// https://pastebin.com/QABMizRy <-- my console output

@LarsZocher
Copy link
Author

// https://pastebin.com/C66n2dbD <-- after a while this was in the console

@goxr3plus
Copy link
Owner

Hello :)

I have readen you code . Multiple mistakes i have seen ( Just to correct you , so you become better).

1)We never stop a Thread using stop() method . Possible it doesn't even exist on Java 9.
2)I need all the code in order to run it , where is the Plugin Manager ? :)

3)Create a repository with your project (in case you want to share it with me and people ) . I will of course help you .

4)Have you created you own GOOGLE_API_KEY or you are using the one from the example :)

Waiting for your response to continue investigation .

@LarsZocher
Copy link
Author

  1. GOOGLE_API_KEY = yours, because i dont know how to create my own, I tried but to get one i need to buy it on google, is there a way to get it free and with no credit card?

  2. I dont know how to create a repository, but i uploaded my project files --> https://mega.nz/#!ug5FXCCb!lzqGzWI6EDGhlzc3x13q8u9ME9YQ1nQonkBuybD4IU4

  3. what can i use instead of "stop()" ?

@LarsZocher
Copy link
Author

// in my file, there are 3 folders,

    1. "ProjectDotBot" is the main project
    1. "ProjectDotBotTestPlugin" is the plugin, who comes after in the plugins folder...
    1. "plugins" here are the plugins.

the plugins are not important, but i make it for later things, (I want to add the "speech commands" in the plugins)

@goxr3plus
Copy link
Owner

goxr3plus commented Sep 22, 2017

1 ) You have to give credit card for GOOGLE_API_KEY , i will make a tutorial about it soon :)

2 ) I want from you to give 30 minutes of your life to learn how to create a repository for Github and how to upload it (GitHub Desktop is a useful application for uploading your files ) . I want you to try .

3 ) Instad of stop() we are using different techniques , like loops with flags and more , search on the web (Best ways to stop java Thread ) , it's quite a complex topic ( Threads are so beautiful once you learn them believe me ... actually it takes years to master the topic IT IS SOMETHING VERY IMPORTANT WITH MODERN COMPUTERS which have multiple CPU CORES )

In the mean time i will read your code and improve it.

@goxr3plus
Copy link
Owner

goxr3plus commented Sep 22, 2017

Try this :

Class DotBot , line 95 you are missing an InterruptedException , so when you stop the Listener something bad happens , try using ¨¨

		try {
		   duplex.recognize(mic.getTargetDataLine(), mic.getAudioFormat());
	        } catch (IOException | LineUnavailableException | InterruptedException e) {
		    e.printStackTrace();
	   }```

@LarsZocher
Copy link
Author

here is my repository --> https://github.com/BubbleEgg/DotBot

@goxr3plus
Copy link
Owner

Also

  1. Use Java Logger for Debugging , all are ready for you :) so you focus on your project
  2. Add comments
  3. Add spaces between codes of lines sometimes ..
  4. :)

@LarsZocher
Copy link
Author

LarsZocher commented Sep 22, 2017

ok, so is the problem fixed?

@LarsZocher
Copy link
Author

and when i try it with the InterruptedException, IntelliJ says that this exeption is never thrown?
what can i do?

@goxr3plus
Copy link
Owner

goxr3plus commented Sep 22, 2017

There is a problem here , even when you stop the Microphone the Thread nevers exits . Add

System.out.println("Exited Listening Thread...."); just before

 });
listening.start();

There is a problem with the library microphone.close(); , hm i need to investigate this and it seems not something easy . Look , keep the interrupted exception , IntelliJ thinks is smarter that Java Compiler maybe lol . Try and tell me if you have again the problem you faced before.

As about the Thread stopping keep in mind the above and i will soon add Java Google Speech Recognition on XR3Player , then you know for soore i will investigate this issue :) .

@LarsZocher
Copy link
Author

it dont let me compile it, with the error

@goxr3plus
Copy link
Owner

goxr3plus commented Sep 22, 2017

Well i got into this . Tell me your application has a pom.xml file ? Yes IntelliJ is correct about InterruptedException, you don't need it , i am using another version of the Java-Speech-Api that i have changed some things ....

In your project you must use V2.02 version of https://github.com/lkuza2/java-speech-api/releases

Though if you are using pom.xml with Maven modify this pom.xml for your needs , you have nothing to download Maven will take care for all the jars . I figured ```java-speech-api`` how to download from https://jitpack.io just know , i will update pom.xml of my repository accordingly .

[Remember this is the jar from the Owner of the Project ] , i am further modifying it to my repository ... [https://github.com/goxr3plus/java-speech-api ] [ The repository i made is experimental so always use the Owners one jar as shown below]

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>JavaGoogleSpeechRecognizer</groupId>
	<artifactId>JavaGoogleSpeechRecognizer</artifactId>
	<version>1.0.0</version>
	<build>
		<sourceDirectory>src</sourceDirectory>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.6.1</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<repositories>
		<repository>
			<id>jitpack.io</id>
			<url>https://jitpack.io</url>
		</repository>
	</repositories>

	<dependencies>
		<dependency>
			<groupId>com.github.lkuza2</groupId>
			<artifactId>java-speech-api</artifactId>
			<version>v2.02</version>
		</dependency>
		<dependency>
			<groupId>net.sourceforge.javaflacencoder</groupId>
			<artifactId>java-flac-encoder</artifactId>
			<version>0.3.7</version>
		</dependency>
		<dependency>
			<groupId>org.json</groupId>
			<artifactId>json</artifactId>
			<version>20150729</version>
		</dependency>
	</dependencies>

	<name>Java Google Speech Recognizer</name>
	<description>Made by GOXR3PLUS STUDIO based on  https://github.com/lkuza2/java-speech-api/</description>
	<organization>
		<name>GOXR3PLUS STUDIO</name>
	</organization>
</project>

@goxr3plus
Copy link
Owner

Since the owner Project released a lot of things have changed along with bug fixes . That might be what causing the problems ... lot of pull requests since [ January 2016 when the V2.02 releases ] -> https://github.com/lkuza2/java-speech-api/commits/master

@LarsZocher
Copy link
Author

so, i dont know how to use the pom.xml can you help me with that or do i need it anyway?, and I am using the V2.02? can you tell me what i have to do now?

@LarsZocher
Copy link
Author

//little update, I tried some things and now it works great. Now I'm using your version of the J.A.R.V.I.S and it workes good, but the method stopSpeechReginison() gives me a NullPointerExeption, so...

-->I use your JARVIS without the stopSpeechReginison() but it works.
thx

@goxr3plus
Copy link
Owner

goxr3plus commented Sep 23, 2017 via email

@LarsZocher
Copy link
Author

ok xD

@goxr3plus
Copy link
Owner

goxr3plus commented Sep 23, 2017

I have fixed your problem and added a new SnapShot jar in my repository .
Look : I am gonna create new github branches , one will transfer this project to Java 8 and some other branches which will contain new features .

I see that the owner of the project doesn't care for pull requests generally , either for emails i send so ....

I modified the repository , added example also how to use :) -> https://github.com/goxr3plus/java-speech-api

@LarsZocher
Copy link
Author

thats good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants