Android, convert call stream to text possible? - android

I have a simple application that needs to call a number and speech-to-text (as best as possible) whatever the other party is saying.
Simply put, if the other party says "Hello", then "Hello" would be displayed on the screen.
I can make a call using Intent.ACTION_CALL:
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:91234567"));
startActivity(callIntent);
However, how do I continue from there, to convert the received audio signals to text?

In Android, you cannot access or modify the call audio stream. Due to this, you cannot get what is being spoken, and hence cannot convert it to text.
This app isn't possible on Android.

Related

what is the purpose of EXTRA_CALLING_PACKAGE in android studio

im now writing STT in android studio and i have a question for some code lines.
intent=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,getPackageName());
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE,"en-US");
The first line is set intent fot getting input of user's speech and the last one is for setting language that we going to use. but what about a second line?
Even though i read public documentation, cannot understand.
'The extra key used in an intent to the speech recognizer for voice search'
i understand that like this: after getting input of speech from the first line, use the input in the intent - and what kind of intent? - to the speech recognizer for voice search.
but still not sure..
can you give me an explanation?4
Thank you in advance
it's a flag that is used by voice search API to identify the called to this API (your application) so the voice search implements the callbacks and ... based on your package name...

android send Dial Tone and detect end of input

I'm developing a little app which needs to start a simple call and send some DTMF tones.
By searching on the net i found that the correct way for doing it should be the following:
Intent i = new Intent("android.intent.action.CALL",
Uri.parse("tel://" + number + "," + dtmfTones));
Now, my problems are 2:
I need to shut down the call after tones are sent.
If possible I would like not to open the default dialer.
My app only needs to perform the call and send the tones, so the user has nothing to do nor interact with and that's why I don't need to open the dialer, it can also be done in background. Is there a way to do those things?
Thanks all and sorry for my not perfect english.
EDIT1: I tryed this method and I performed a call to another mobile number I have under control. The tones are sent and you can listen them without any problem.
EDIT2: i found also some apps which uses an unusual sequence of "#", ",", ".". but it is still not working, any idea?
I tryed to perform the same call to the house number which has to reply (it's a security system) but it doesn't recognize them. I don't know what I'm missing.

Why does an "Intent Selector" exists, what is it used for?

Android's Intent class provides an API called setSelector. I am trying to understand it from the example given in the documentation.
I want to ask that why did Android need to add this API ? What was breaking in Intent before this API ?
My understanding from reading the references is that the problem this API is intending to solve is where you want to send a launcher intent for an app that meets some general restrictions. Say you want to match all apps that open .mp3 files, but you don't want to actually open an mp3 file, you just want to launch an app that supports that. In that case, you could create a generic ACTION_MAIN, CATEGORY_LAUNCHER intent, and set the selector to an intent with an mp3 mime type or data URI.
Before this API there would be no way to do that - if you wanted to target an app that supports opening mp3s, you would have to send an intent for an mp3, which could either cause music to start playing, or cause the music player to throw an error. Also, depending on the music player's launch mode, the launcher intent may return to an existing instance of the music player, while the mp3 intent might create a new one.
According to my understanding, it gives choice to user which intent he wants to select. In that documentation they have given that it gives selection of intents whether user wants to open app's main activity or wants to launch any diff app/activity other than user's app. This is what i understood from that documentation. Check this links for your reference : https://code.google.com/p/android/issues/detail?id=67162 & http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4_r1/android/content/Intent.java#Intent.setSelector%28android.content.Intent%29

Android & iOS access number dialing

I am very new to both these operating systems so please excuse me if my question is basic :-)
We are planning a secure dialing system which means dialiing 2 numbers in one phone number dailing session.
Currently we have a system which allows us to dail an access number, wait for a tone and then dial a full telephone number.
It's a bit elaborate but like I said, it's a security feature.
What we are now trying to do is create Android and iPhone apps that will allow us to dial the access number + telephone number at the click of a virtual button :-)
Can anyone tell me how this can be accomplished programmatically? I need to implement something like access-number#phone-number or anything that works.
Thanks.
Both iphone and android support making phone calls in the same sort of manner.
You need to construct a URL and 'run' the url. Both iphone and android don't support any sort of call control so you have to make do with the url to make a phone call. They both support 'pause' character and dtmf tones in the url.
The iphone don't support some characters, notably the '#' and '*' characters. Because the '#' character is not supported (for security reasons), it can make it hard dealing with PBX systems.
On the android you have to 'encode' characters manually or using URLEncoder. I have not had any luck supporting the '#' character in Android but I have seen reports of it working. You will need to test this to see if it works for you.
For iphone you use the UIApplication openURL: to a tel link.
e.g.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:123456p12345"]];
For android you use the INTENT_DIAL or ACTION_CALL.
INTENT_CALL will display the phone dialler with you number filled out. It does not require any special setup.
e.g.
Intent dialIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:123456"));
startActivity(dialIntent);
ACTION_CALL requires the CALL_PHONE permission in your manifest file.
e.g.
AndroidManifest.xml:
Intent dialIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:123456%2C12345"));
startActivity(dialIntent);
I'm not quite sure if this is what you're looking for but.
You could create a button in your layout.
Create a pointer to it in your main activity // findViewById();
OnClickListener on the Button.
in the onClick, fire a Dial Intent with the number of choice.
If this isn't what you're looking for I'm afraid I'll need a bit more information on what it truely is, because at this point that's the only thing I can manage to think of with the description given.

Voice recognition on android with recorded sound clip?

I've used the voice recognition feature on Android and I love it. It's one of my customers' most praised features. However, the format is somewhat restrictive. You have to call the recognizer intent, have it send the recording for transcription to google, and wait for the text back.
Some of my ideas would require recording the audio within my app and then sending the clip to google for transcription.
Is there any way I can send an audio clip to be processed with speech to text?
I got a solution that is working well to have speech recognizing and audio recording. Here is the link to a simple Android project I created to show the solution's working. Also, I put some print screens inside the project to illustrate the app.
I'm gonna try to explain briefly the approach I used. I combined two features in that project: Google Speech API and Flac recording.
Google Speech API is called through HTTP connections. Mike Pultz gives more details about the API:
"(...) the new [Google] API is a full-duplex streaming API. What this means, is that it actually uses two HTTP connections- one POST request to upload the content as a “live” chunked stream, and a second GET request to access the results, which makes much more sense for longer audio samples, or for streaming audio."
However, this API needs to receive a FLAC sound file to work properly. That makes us to go to the second part: Flac recording
I implemented Flac recording in that project through extracting and adapting some pieces of code and libraries from an open source app called AudioBoo. AudioBoo uses native code to record and play flac format.
Thus, it's possible to record a flac sound, send it to Google Speech API, get the text, and play the sound that was just recorded.
The project I created has the basic principles to make it work and can be improved for specific situations. In order to make it work in a different scenario, it's necessary to get a Google Speech API key, which is obtained by being part of Google Chromium-dev group. I left one key in that project just to show it's working, but I'll remove it eventually. If someone needs more information about it, let me know cause I'm not able to put more than 2 links in this post.
Unfortunately not at this time. The only interface currently supported by Android's voice recognition service is the RecognizerIntent, which doesn't allow you to provide your own sound data.
If this is something you'd like to see, file a feature request at http://b.android.com. This is also tangentially related to existing issue 4541.
As far as I know there is still no way to directly send an audio clip to Google for transcription. However, Froyo (API level 8) introduced the SpeechRecognizer class, which provides direct access to the speech recognition service. So, for example, you can start playback of an audio clip and have your Activity start the speech recognizer listening in the background, which will return results after completion to a user-defined listener callback method.
The following sample code should be defined within an Activity since SpeechRecognizer's methods must be run in the main application thread. Also you will need to add the RECORD_AUDIO permission to your AndroidManifest.xml.
boolean available = SpeechRecognizer.isRecognitionAvailable(this);
if (available) {
SpeechRecognizer sr = SpeechRecognizer.createSpeechRecognizer(this);
sr.setRecognitionListener(new RecognitionListener() {
#Override
public void onResults(Bundle results) {
// process results here
}
// define your other overloaded listener methods here
});
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
// the following appears to be a requirement, but can be a "dummy" value
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "com.dummy");
// define any other intent extras you want
// start playback of audio clip here
// this will start the speech recognizer service in the background
// without starting a separate activity
sr.startListening(intent);
}
You can also define your own speech recognition service by extending RecognitionService, but that is beyond the scope of this answer :)

Categories

Resources