- AudioTranslateDemo is a demo of the OpenAI Whisper transcription and translation model released and discussed in this paper. It is a simple web frontend that allows you to upload an audio file and translate it to text. The text is then translated to another language and spoken back to you.
This repository demonstrates deployment of a Streamlit application to the Google Cloud Platform. In particular, it exercises several features:
- OpenAI Whisper transcription and translation model in a single deep learning model (unlike the traditional two phase system of Automatic Speech Recognition and Translation)
- Cloud Run for hosting the application in a way that can facilitate scale to zero (no resources are consumed if the service is not being actively used)
- Streamlit for the web frontend
- Docker for containerization
- Google Cloud Build for building the container and deploying to Cloud Run
- Google Cloud Artifact Registry for storing the container image
To try things out, you can use the live demo at https://audio.nyctaxi.me/. If deploying another instance is the goal, then read on.
- Build the Docker container locally
bash container_build.sh
- Test the container locally
docker run -p 8080:8080 -it us-east1-docker.pkg.dev/gcloudsdk-on-wmm/gdocker/audiotranslatedemo:v20221121a
Then browse to http://localhost:8080/ to see the Streamlit application running locally.
- Upload the container to Google Artifact Registry
UPLOAD=1 bash container_build.sh
-
Determine the DNS names of the frontend server for your deployment
-
Instantiate and configure the container in Google Cloud Run on the Google Cloud console.
To interact with the deployed demo system, browse to https://audio.nyctaxi.me/.
- Make the demo look nicer in streamlit
- The streamlit audio recorder does not seem to be stable on mobile devices. Investigate alternatives.
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
William Groves - @willgrovesemail
Project Link: https://github.com/willgroves/audiotranslatedemo
- Widget for recording audio in streamlit frontends: here
- Deploying to Google Cloud Platform App Engine seems well documented: here
- A tutorial on deploying Streamlit applications to Google Cloud Run can be found here.
- Another article
- Name collisions for paths ending in the character z does seem to be a problem for GCP (e.g. /healthz, which is a core component of streamlit): here
- A great template: Best-README-Template
It is also possible to run the whisper model from the command line with examples like below:
whisper src/audio.wav --language zh
whisper src/audio.wav --language zh --task translate