Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat 4155 Text To Speech in Python #172

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Mushmou
Copy link

@Mushmou Mushmou commented Aug 3, 2023

Feat 4155: Add TextToSpeech function in Python

Checklist:

  • Ask to be assigned to the issue.
  • Implement function textToSpeech() in Python/ folder.
  • Manually execute the newly implemented function to ensure it works.
  • 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 the main.py file with various scenarios like happy paths, value errors, unexpected exceptions etc. test_main.py uses result.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:https://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

image
  • Azure

Azure Curl Example (Supports API_KEY in Environment Variables)

curl http:https://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

image
  • AWS

AWS Curl Example (Supports API_KEY and SECRET_API_KEY in Environment Variables)

curl http:https://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

image

@rubynguyen1510
Copy link

@Mushmou

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants