Monday, July 21, 2025

Ai voice download

Flask gTTS from flask import Flask, request, send_file from gtts import gTTS import io app = Flask(__name__) @app.route('/tts', methods=['POST']) def tts(): data = request.json text = data.get('text', '') lang = data.get('lang', 'en') # Generate mp3 tts = gTTS(text=text, lang=lang) mp3_bytes = io.BytesIO() tts.write_to_fp(mp3_bytes) mp3_bytes.seek(0) return send_file(mp3_bytes, as_attachment=True, download_name='tts_output.mp3', mimetype='audio/mpeg') @app.route('/') def index(): return "TTS Server is running" if __name__ == '__main__': app.run(host='0.0.0.0', port=5000) pip install -r requirements.txt python app.py http://localhost:5000 Text to Voice Downloader

Text to Voice + Download (MP3)

from flask import Flask, request, send_file, send_from_directory # ... @app.route('/') def homepage(): return send_from_directory('static', 'index.html')

No comments:

Post a Comment