How do you get audio input from a file?

I am writing apps that help you learn singing, see for instance the first one, Pitch Plotter version 2 User Guide - Google Docs

This app plots the pitch of what you sing, and lets you see how accurately you hit permitted notes.

Is there a way to play an audio file, and redirect the audio into such an app? Or, for that matter feed audio from a file into the SpeechRecognizer or any component that is designed to get audio from the mike?


you can use this extension to pick an audio file from "File Manager", and after that play
the audio using (Player1 Component) :wink:

App Inventor Extensions: File | Pura Vida Apps

Let me explain my problem more clearly. In App Inventor, there are components that let you process audio, e.g. SpeechRecognizer, but these take their input from the mike.

Is there any way I could feed audio from a file into such components? The solution you propose, Salman, would require me to use two phones, one to play the audio, and the other to run my app on. Can't I do this with a single phone?

warmly and gratefully,

Please explain what exactly is the goal of your app? Give us a concrete example.

Recording an audio file and accessing it later is no problem at all (for example using the SoundRecoder component). So where exactly is your problem and what is intended?

Thank you for your suggestion, Anke. You can do lots with audio other than just listen to it. SpeechRecognizer converts audio into text, for instance.

My app Pitch Plotter, (Pitch Plotter version 2 User Guide - Google Docs) plots the pitch of the audio from the mike on the y axis, versus time on the x axis. Horizontal lines show you the pitch of the notes C, D etc so you can easily see how pitchy you sing. To detect the pitch of the input sound, I use the extension SoundAnalysis, MIT App Inventor Extensions . This extension only works for audio input from mike, not from file.

The follow up app which is almost done lets a teacher record her pitch plot, and send it to the student, who attempts to trace the pitch plot of the teacher using his own voice.

If I could take audio from a file and process it this way, I could easily learn any song, since my app could allow me to use its pitch plot as a background when I am singing, and tracing it using my voice.

I could use one phone to play the audio file, and another phone to plot the pitch, but can't I use just one phone, redirect audio from a file, so that it appears to my app to be coming in from the mike?

Thank you for your patience.