Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
-
from
|
|
|
|
|
|
|
| 2 |
from bs4 import BeautifulSoup
|
| 3 |
from scraper import voicevox
|
| 4 |
import requests
|
|
@@ -18,7 +20,9 @@ def voicevox_resp():
|
|
| 18 |
|
| 19 |
try:
|
| 20 |
data = voicevox(text, speaker=speaker)
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
except Exception as e:
|
| 23 |
return jsonify({'error': str(e)}), 500
|
| 24 |
|
|
|
|
| 1 |
+
from io import BytesIO
|
| 2 |
+
|
| 3 |
+
from flask import Flask, request, jsonify, render_template, send_file
|
| 4 |
from bs4 import BeautifulSoup
|
| 5 |
from scraper import voicevox
|
| 6 |
import requests
|
|
|
|
| 20 |
|
| 21 |
try:
|
| 22 |
data = voicevox(text, speaker=speaker)
|
| 23 |
+
io = BytesIO(data)
|
| 24 |
+
|
| 25 |
+
return send_file(io, as_attachment=True, mimetype="audio/mp3")
|
| 26 |
except Exception as e:
|
| 27 |
return jsonify({'error': str(e)}), 500
|
| 28 |
|