Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from flask import Flask, send_file, request
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
import uuid
|
|
@@ -6,7 +6,28 @@ import uuid
|
|
| 6 |
app = Flask(__name__)
|
| 7 |
AUDIO_DIR = "/tmp/tts_audio"
|
| 8 |
os.makedirs(AUDIO_DIR, exist_ok=True)
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
@app.route('/speak')
|
| 11 |
def speak():
|
| 12 |
text = request.args.get('input', '')
|
|
|
|
| 1 |
+
from flask import Flask, send_file, request, render_template_string
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
import uuid
|
|
|
|
| 6 |
app = Flask(__name__)
|
| 7 |
AUDIO_DIR = "/tmp/tts_audio"
|
| 8 |
os.makedirs(AUDIO_DIR, exist_ok=True)
|
| 9 |
+
@app.route('/')
|
| 10 |
+
def home():
|
| 11 |
+
return render_template_string('''
|
| 12 |
+
<!DOCTYPE html>
|
| 13 |
+
<html>
|
| 14 |
+
<head>
|
| 15 |
+
<title>eSpeak NG TTS API</title>
|
| 16 |
+
<style>
|
| 17 |
+
body { font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px; }
|
| 18 |
+
code { background: #f4f4f4; padding: 2px 5px; }
|
| 19 |
+
</style>
|
| 20 |
+
</head>
|
| 21 |
+
<body>
|
| 22 |
+
<h1>eSpeak NG Text-to-Speech API</h1>
|
| 23 |
+
<p>Use the endpoint below to generate speech:</p>
|
| 24 |
+
<code>GET /speak?input=Your+Text+Here</code>
|
| 25 |
+
<p>Example:</p>
|
| 26 |
+
<a href="/speak?input=Hello+World" target="_blank">/speak?input=Hello+World</a>
|
| 27 |
+
<p>Returns: Raw MP3 audio.</p>
|
| 28 |
+
</body>
|
| 29 |
+
</html>
|
| 30 |
+
''')
|
| 31 |
@app.route('/speak')
|
| 32 |
def speak():
|
| 33 |
text = request.args.get('input', '')
|