Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created November 13, 2020 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/6b57769b54148867e0bab5fe574ef38f to your computer and use it in GitHub Desktop.
Save parzibyte/6b57769b54148867e0bab5fe574ef38f to your computer and use it in GitHub Desktop.
"""
Reproducir sonido a partir de texto con Python
https://parzibyte.me/blog
"""
from flask import Flask, request
import pyttsx3
NUMBER_OF_TIMES_REPEAT_AUDIO = 2
app = Flask(__name__)
@app.route('/')
def play_sound():
text = request.args.get("text")
if not text:
return ""
else:
engine = pyttsx3.init()
engine.setProperty("rate", 150)
for _ in range(NUMBER_OF_TIMES_REPEAT_AUDIO):
engine.say(text)
engine.runAndWait()
return ""
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8000, debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment