()
| 28 | @app.route('/audio/speech', methods=['POST']) # Add this line for the alias |
| 29 | @require_api_key |
| 30 | def text_to_speech(): |
| 31 | data = request.json |
| 32 | if not data or 'input' not in data: |
| 33 | return jsonify({"error": "Missing 'input' in request body"}), 400 |
| 34 | |
| 35 | text = data.get('input') |
| 36 | |
| 37 | if not REMOVE_FILTER: |
| 38 | text = prepare_tts_input_with_context(text) |
| 39 | |
| 40 | # model = data.get('model', DEFAULT_MODEL) |
| 41 | voice = data.get('voice', DEFAULT_VOICE) |
| 42 | |
| 43 | response_format = data.get('response_format', DEFAULT_RESPONSE_FORMAT) |
| 44 | speed = float(data.get('speed', DEFAULT_SPEED)) |
| 45 | |
| 46 | mime_type = AUDIO_FORMAT_MIME_TYPES.get(response_format, "audio/mpeg") |
| 47 | |
| 48 | # Generate the audio file in the specified format with speed adjustment |
| 49 | output_file_path = generate_speech(text, voice, response_format, speed) |
| 50 | |
| 51 | # Return the file with the correct MIME type |
| 52 | return send_file(output_file_path, mimetype=mime_type, as_attachment=True, download_name=f"speech.{response_format}") |
| 53 | |
| 54 | @app.route('/v1/models', methods=['GET', 'POST']) |
| 55 | @app.route('/models', methods=['GET', 'POST']) |
nothing calls this directly
no test coverage detected