lkuza2 / java-speech-api

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.
GNU General Public License v3.0
535 stars 301 forks source link

LineUnavailableException #39

Closed EricZeiberg closed 10 years ago

EricZeiberg commented 10 years ago

Whenever I try to run mic.captureAudioToFile, it gives me a javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 8000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported error

Here's my code - https://gist.github.com/MasterEjay/11126602

Skylion007 commented 10 years ago

You need to close the microphone before you reopen it. The issue comes from the fact that you keep trying to run the code over and over again with only one if statement terminating in the mic.close() being called. I've forked the gist, but I do not know how to submit a pull request so just check out my fork to solve the issue.

EricZeiberg commented 10 years ago

Its still throwing the line with format PCM_SIGNED 8000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported error.

EricZeiberg commented 10 years ago

Yes, my computer does have a microphone. I was trying the api out before, and it did correctly get what I said. So, its definitely getting my mic. The error only happens when I speak above the threshold.

On Sun, Apr 20, 2014 at 9:34 PM, Aaron Gokaslan notifications@github.comwrote:

Does your computer even have a microphone? If it does, look up what audio formats it supports and override the getAudioFormat() method in microphone.

— Reply to this email directly or view it on GitHubhttps://github.com/The-Shadow/java-speech-api/issues/39#issuecomment-40910535 .

EricZeiberg commented 10 years ago

Hellooo?

mayukhnair commented 10 years ago

Where has Aaron vanished?

I need help too. Eric, if you can help me, please have a look at my issue.

https://github.com/The-Shadow/java-speech-api/issues/40

On Thu, Apr 24, 2014 at 2:54 AM, Eric Zeiberg notifications@github.comwrote:

Hellooo?

— Reply to this email directly or view it on GitHubhttps://github.com/The-Shadow/java-speech-api/issues/39#issuecomment-41216724 .

With my sincere greetings, Mayukh Nair

Skylion007 commented 10 years ago

Sigh, can't a guy go on vacation. Anyway to the point, you need to close the microphone before writing to a second audio file as is the case with filename1. Microphone can only write to one file at a time. If you are just using the microphone to detect volume, use mic.open() instead of mic.captureAudioToFile(String). Mic.open() allows you to get metrics such as volume while allowing the targetdataline to be available.

EricZeiberg commented 10 years ago

Ok, I'll try that when I get home. Thanks :)

On Thu, Apr 24, 2014 at 8:10 AM, Aaron Gokaslan notifications@github.comwrote:

Sigh, can't a guy go on vacation. Anyway to the point, you need to close the microphone before writing to a second audio file as is the case with filename1. Microphone can only write to one file at a time. If you are just using the microphone to detect volume, use mic.open() instead of mic.captureAudioToFile(String). Mic.open() allows you to get metrics such as volume while allowing the targetdataline to be available.

— Reply to this email directly or view it on GitHubhttps://github.com/The-Shadow/java-speech-api/issues/39#issuecomment-41272400 .

mayukhnair commented 10 years ago

Sigh, the price of maintaining an on-fire GitHub repo.

On Thursday, April 24, 2014, Eric Zeiberg notifications@github.com wrote:

Ok, I'll try that when I get home. Thanks :)

On Thu, Apr 24, 2014 at 8:10 AM, Aaron Gokaslan notifications@github.com<javascript:_e(%7B%7D,'cvml','notifications@github.com');>wrote:

Sigh, can't a guy go on vacation. Anyway to the point, you need to close the microphone before writing to a second audio file as is the case with filename1. Microphone can only write to one file at a time. If you are just using the microphone to detect volume, use mic.open() instead of mic.captureAudioToFile(String). Mic.open() allows you to get metrics such as volume while allowing the targetdataline to be available.

— Reply to this email directly or view it on GitHub< https://github.com/The-Shadow/java-speech-api/issues/39#issuecomment-41272400>

.

— Reply to this email directly or view it on GitHubhttps://github.com/The-Shadow/java-speech-api/issues/39#issuecomment-41283198 .

With my sincere greetings, Mayukh Nair

EricZeiberg commented 10 years ago

Still throwing the same error, heres my class - https://gist.github.com/MasterEjay/11267714

Skylion007 commented 10 years ago

Now you are using two microphone objects? That will cause an error as well. Just reuse the MicrophoneAnalyzer class, it extends the Microphone class. Your setup is unnecessarily complicated. The microphone class assumes control of the TargetDataLine which directly controls the entire microphone. Try reducing it to one Microphone class. Unfortunately, TargetDataLine requires that it has full control over the hardware in question. For this reason, you cannot call two TargetDataLines at the same time.

On Thu, Apr 24, 2014 at 4:08 PM, Eric Zeiberg notifications@github.comwrote:

Still throwing the same error, heres my class - https://gist.github.com/MasterEjay/11267714

— Reply to this email directly or view it on GitHubhttps://github.com/The-Shadow/java-speech-api/issues/39#issuecomment-41325846 .

EricZeiberg commented 10 years ago

Really sorry to keep pestering you about this, but its still giving me the error. https://gist.github.com/MasterEjay/11274633

Skylion007 commented 10 years ago

Sorry about that, I just was able to reproduce the bug and just committed a patch. Sorry, it was a regression in one of the newer versions of the API. Thank you so much for the information.

EricZeiberg commented 10 years ago

Arrg, still not working for me. I grabbed your code changes to Microphone class and built my own version.

Skylion007 commented 10 years ago

Is it still throwing the same error?

EricZeiberg commented 10 years ago

Yes

On Sat, Apr 26, 2014 at 12:31 PM, Aaron Gokaslan notifications@github.comwrote:

Is it still throwing the same error?

— Reply to this email directly or view it on GitHubhttps://github.com/The-Shadow/java-speech-api/issues/39#issuecomment-41473279 .

Skylion007 commented 10 years ago

First of all, the code you posted is a mess. You don't want to call dozens of mic.captureAudioFile in a loop, it's not a good idea. Try using these two methods I wrote: https://gist.github.com/Skylion007/11325165

EricZeiberg commented 10 years ago

Thanks, but that doesn't seem to be working either. (omg) Its creating a weird file called AudioTestNow.wav.flac instead of just AudioTestNow.wav.

Skylion007 commented 10 years ago

Because you are converting the file to FLAC. -_- Is there anyway I can contact you? This might be easier over chat.

EricZeiberg commented 10 years ago

Yeah, sure, what's your skype?

On Sat, Apr 26, 2014 at 1:26 PM, Aaron Gokaslan notifications@github.comwrote:

Because you are converting the file to FLAC. -_- Is there anyway I can contact you? This might be easier over chat.

— Reply to this email directly or view it on GitHubhttps://github.com/The-Shadow/java-speech-api/issues/39#issuecomment-41474828 .

Skylion007 commented 10 years ago

http://pastebin.com/QpqmnbN4

Skylion007 commented 10 years ago

Glad to see upgrading the latest release solved the issue.

EricZeiberg commented 10 years ago

Me too! Thanks for all your help Aaron. If I'd been in your position, I would have said "Get lost" to me a while back :)

On Sat, Apr 26, 2014 at 1:56 PM, Aaron Gokaslan notifications@github.comwrote:

Glad to see upgrading the latest release solved the issue.

— Reply to this email directly or view it on GitHubhttps://github.com/The-Shadow/java-speech-api/issues/39#issuecomment-41475737 .