@@ -531,6 +531,10 @@ def generate_speech():
531531 ), 400
532532
533533 effective_format = get_supported_format (format_enum )
534+ if len (input_text ) > max_length and auto_combine and effective_format is AudioFormat .MP3 :
535+ effective_format = AudioFormat .WAV
536+ if len (text ) > max_length and effective_format is AudioFormat .MP3 :
537+ effective_format = AudioFormat .WAV
534538
535539 logger .info (
536540 "Generating speech: text='%s...', voice=%s, requested_format=%s (effective=%s)" ,
@@ -656,8 +660,9 @@ def generate_speech_combined():
656660 return jsonify ({"error" : "Invalid voice or format specified" }), 400
657661
658662 logger .info (
659- "Generating combined speech for long text: %s characters, splitting into chunks " ,
663+ "Combining long text ( %s chars) using format %s " ,
660664 len (text ),
665+ effective_format .value ,
661666 )
662667
663668 # Generate speech chunks
@@ -667,7 +672,7 @@ def generate_speech_combined():
667672 responses = client .generate_speech_long_text (
668673 text = text ,
669674 voice = voice_enum ,
670- response_format = format_enum ,
675+ response_format = effective_format ,
671676 instructions = instructions ,
672677 max_length = max_length ,
673678 preserve_words = preserve_words ,
@@ -717,8 +722,10 @@ def generate_speech_combined():
717722 'X-Audio-Size' : str (len (combined_audio )),
718723 'X-Chunks-Combined' : str (len (responses )),
719724 'X-Original-Text-Length' : str (len (text )),
725+ 'X-Auto-Combine' : 'true' ,
726+ 'X-Powered-By' : 'TTSFM-OpenAI-Compatible' ,
720727 'X-Requested-Format' : format_enum .value ,
721- 'X-Effective-Format' : get_supported_format ( format_enum ) .value
728+ 'X-Effective-Format' : effective_format .value
722729 }
723730
724731 return Response (
@@ -770,7 +777,7 @@ def get_status():
770777 return jsonify ({
771778 "status" : "online" ,
772779 "tts_service" : "openai.fm (free)" ,
773- "package_version" : "3.3.0-alpha5 " ,
780+ "package_version" : "3.3.0-beta1 " ,
774781 "timestamp" : datetime .now ().isoformat ()
775782 })
776783
@@ -789,7 +796,7 @@ def health_check():
789796 """Simple health check endpoint."""
790797 return jsonify ({
791798 "status" : "healthy" ,
792- "package_version" : "3.3.0-alpha5 " ,
799+ "package_version" : "3.3.0-beta1 " ,
793800 "timestamp" : datetime .now ().isoformat ()
794801 })
795802
@@ -924,15 +931,16 @@ def openai_speech():
924931 if len (input_text ) > max_length and auto_combine :
925932 # Long text with auto-combine enabled: split and combine
926933 logger .info (
927- "Long text detected (%s chars), auto-combining enabled " ,
934+ "Long text detected (%s chars); auto-combining with format %s " ,
928935 len (input_text ),
936+ effective_format .value ,
929937 )
930938
931939 # Generate speech chunks
932940 responses = client .generate_speech_long_text (
933941 text = input_text ,
934942 voice = voice_enum ,
935- response_format = format_enum ,
943+ response_format = effective_format ,
936944 instructions = instructions ,
937945 max_length = max_length ,
938946 preserve_words = True
0 commit comments