rull commited on
Commit
01d0b27
·
verified ·
1 Parent(s): 0225001

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -1,4 +1,6 @@
1
- from flask import Flask, request, jsonify, render_template, send_bytes
 
 
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
- return send_bytes(data), 200
 
 
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