examples
examples copied to clipboard
Feat 4155 Text To Speech in Python
Feat 4155: Add TextToSpeech function in Python
Checklist:
- [x] Ask to be assigned to the issue.
- [X] Implement function textToSpeech() in Python/ folder.
- [X] Manually execute the newly implemented function to ensure it works.
- [X] Submit a pull request in open-runtimes/examples and include screenshots of successful execution.
Closes #4155.
Authors: Noah Jacinto, Ngoc Nguyen.
Summary
This pull request introduces a function that converts text into spoken audio using Google, Azure, and AWS APIs. To achieve this, the function will receive a request containing essential information such as the chosen provider, the desired language, and the input text. Additionally, the necessary environment variables will be provided, containing the required settings for the chosen provider. The function will return the converted text into audio in the form of bytes.
Details
-
README.md
contains instructions on how to run the main function. -
main.py
contains functions to validate common, requests, and perform speech synthesis Google, Azure, and AWS. -
requirements.txt
contains Python packages and dependencies used for our build. -
test_main.py
contains unittest for themain.py
file with various scenarios like happy paths, value errors, unexpected exceptions etc.test_main.py
usesresult.txt
as a sample speech synthesis result.
Testing
More information about setting up the environment, refer to README.md
.
-
Google
Google Curl Example (Supports only API_KEY and PROJECT_ID in Environment Variables)
curl http://localhost:3000/ -H "X-Internal-Challenge: secret-key" -H "Content-Type: application/json" -d '{"payload": {"provider": "google", "language": "en-US", "text": "Hello World!"}, "variables": {"API_KEY": "<YOUR_API_KEY>", "PROJECT_ID": "<YOUR_PROJECT_ID>"}}'
Result
-
Azure
Azure Curl Example (Supports API_KEY in Environment Variables)
curl http://localhost:3000/ -H "X-Internal-Challenge: secret-key" -H "Content-Type: application/json" -d '{"payload": {"provider": "azure", "language":"en-US", "text": "Hello World!"}, "variables": {"API_KEY": "<YOUR_API_KEY>"}}'
Result
-
AWS
AWS Curl Example (Supports API_KEY and SECRET_API_KEY in Environment Variables)
curl http://localhost:3000/ -H "X-Internal-Challenge: secret-key" -H "Content-Type: application/json" -d '{"payload": {"provider": "aws", "language":"en-US", "text":"Hello World!"}, "variables": {"API_KEY": "<YOUR_API_KEY>", "SECRET_API_KEY": "<YOUR_SECRET_API_KEY>"}}'
Result
@Mushmou