How can you switch audio from earphone to speaker?

I have written a free app for severely disabled persons that lets you, via simple hand or foot movement, select a pre-written sentence and use text to speech to say it for the environment to hear, please see EyeBlink v4 User Guide - Google Docs

But what if the patient cannot see the screen? In that case, I was thinking, perhaps the app could say the sentences one by one in the ear of the patient, and when she or he moves the phone, say the one just heard through the earphone out loud via the speaker. Is such switching possible in the app?

Many thanks to those who have helped selflessly before!
Arun Mehta

1 Like

oops sorry, link to the wrong app in the original post, here is the correct one:


1 Like

OMG I'm really sorry for going off topic, but you are the guy who wrote software to help Stephen hawking communicate!!! I've seen and heard about you multiple times!!! Its really nice to have you in our forum!!! Welcome!!!

So in simple words, you need to once play the audio in the speaker, and ones in the earphone or a different audio device, am I right?

Many thanks, Kumaraswamy, for remembering! The software for Professor Stephen Hawking is described in detail in a chapter I wrote for the OReilly book "Beautiful Code." He had ALS, and I now work closely with the ALS Foundation to help others with the disease, please see Redirecting...

Responding to your subsequent post, I could solve the problem using two phones, one which the user listens to via earphone and then moves to transmit the text to another phone, which then speaks it out through the speaker. But I certainly prefer to solve this using a single device!

1 Like

Hi, I just wrote a simple extension that helps to do what you described.
It helps you to switch headphone/speaker mode to decide where the audio is played.

Using the AudioTrackX, you can request the system to alter between speaker and earphones/headphones mode.

I've attached the project below, when the checkbox is ticked, the audio is played through speaker, else by default it choose the connected external audio device.

Moreover, additionally the extension also offers a way to query available Audio Devices using the QueryAudioDevices block.

AudioTestX.aia (49.9 KB)
xyz.kumaraswamy.audiotrackx.aix (7.3 KB)

I hope this helps in your project! Please let me know the result.

Thanks you, :smiley:


Thank you for all your effort in helping me, but this doesn't work for me. It plays through the speaker, never the earphone. Let me try playing a bit with the aix and get back to you.

1 Like

When the Button 1 (Query Available Audio Outputs) do you see your connected Earphone/Headphone in the list displayed?

Also, to know more, can you please describe the Android version, model/brand you are using which may help us?

Sorry, I spoke too soon. I discovered that if I use a bluetooth speaker, and plug wired earphones into the phone, your app works beautifully! I can switch between the two... it's two devices, but at least not two phones.

Many thanks, Kumaraswamy and others in this forum who are so generous with their support!


1 Like

That's great! I'm happy that my contribution is someway helpful to you! :smiley:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.