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

Add endpoint for Text-To-Speech conversion #1397

Merged
merged 1 commit into from
Oct 29, 2024
Merged

Add endpoint for Text-To-Speech conversion #1397

merged 1 commit into from
Oct 29, 2024

Conversation

ManishMadan2882
Copy link
Collaborator

@ManishMadan2882 ManishMadan2882 commented Oct 28, 2024

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

    • Adding /api/tts endpoint to get audio_base64 in the response
    • Created abstraction in application/tts, with GoogleTTS for conversion to Audio with in-memory storage.
  • Why was this change needed? (You can also link to an open issue here)
    🚀 Feature: Text-to-Speech for Model Output #1202

  • Other information:

Request body

Method: POST

{
    text:"Hi, How are you?"
}

Response body

{
  success:true,
  audio_base64: "//OExAAAAAAAAAAAAA....",
  lang:"en"
}

Copy link

vercel bot commented Oct 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-gpt ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 9:55pm
nextra-docsgpt ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 9:55pm

@github-actions github-actions bot added the application Application label Oct 28, 2024
audio_base64, detected_language = tts_instance.text_to_speech()
return make_response(jsonify({"success": True,'audio_base64': audio_base64,'lang':detected_language}), 200)
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix AI 3 months ago

To fix the problem, we should avoid returning the raw exception message to the user. Instead, we should log the detailed error message on the server and return a generic error message to the user. This approach ensures that sensitive information is not exposed while still allowing developers to debug issues using the server logs.

  • Modify the exception handling block to log the detailed error message.
  • Return a generic error message to the user.
Suggested changeset 1
application/api/user/routes.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/application/api/user/routes.py b/application/api/user/routes.py
--- a/application/api/user/routes.py
+++ b/application/api/user/routes.py
@@ -1687,3 +1687,4 @@
         except Exception as err:
-            return make_response(jsonify({"success": False, "error": str(err)}), 400)
+            app.logger.error(f"Error in TextToSpeech endpoint: {err}")
+            return make_response(jsonify({"success": False, "message": "An internal error has occurred."}), 500)
 
EOF
@@ -1687,3 +1687,4 @@
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
app.logger.error(f"Error in TextToSpeech endpoint: {err}")
return make_response(jsonify({"success": False, "message": "An internal error has occurred."}), 500)

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@ManishMadan2882 ManishMadan2882 changed the title Add endpoint for Text-To-Speech conversation Add endpoint for Text-To-Speech conversion Oct 28, 2024
@dartpain dartpain merged commit 631e77c into main Oct 29, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants