Merge pull request #344 from GenericMale/fix-openai-fields

Fix optional fields in OpenAI API
This commit is contained in:
erew123 authored and GitHub committed 2024-09-14 18:45:37 +01:00
commit a1b22c4ca1
2 files changed
+7 -7

No files matched your search

+3 -3
View File
@@ -214,7 +214,7 @@ def run_firsttime_script():
else: else:
script_path = os.path.join(this_dir, 'system', 'config', 'firstrun.py') # Default to Standalone if nothing matched. script_path = os.path.join(this_dir, 'system', 'config', 'firstrun.py') # Default to Standalone if nothing matched.
subprocess.run(['python', script_path], check=True) subprocess.run([sys.executable, script_path], check=True)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print(f"Error occurred while running the script: {e}") print(f"Error occurred while running the script: {e}")
except Exception as e: except Exception as e:
@@ -356,7 +356,7 @@ if os.path.isfile("/.dockerenv") and 'google.colab' not in sys.modules:
print(f"[{branding}TTS] Internal Gradio address: http://localhost:{params['gradio_port_number']}") print(f"[{branding}TTS] Internal Gradio address: http://localhost:{params['gradio_port_number']}")
# Start the subprocess (now unified for both Docker and non-Docker environments) # Start the subprocess (now unified for both Docker and non-Docker environments)
process = subprocess.Popen(["python", script_path]) process = subprocess.Popen([sys.executable, script_path])
# Check if the subprocess has started successfully # Check if the subprocess has started successfully
if process.poll() is None: if process.poll() is None:
@@ -468,7 +468,7 @@ check_espeak_ng()
def start_subprocess(): def start_subprocess():
global process global process
if process is None or process.poll() is not None: if process is None or process.poll() is not None:
process = subprocess.Popen(["python", script_path]) process = subprocess.Popen([sys.executable, script_path])
return "Subprocess started." return "Subprocess started."
else: else:
return "Subprocess is already running." return "Subprocess is already running."
+4 -4
View File
@@ -741,8 +741,8 @@ async def openai_tts_generate(request: Request):
model = json_data["model"] # Currently ignored model = json_data["model"] # Currently ignored
input_text = json_data["input"] input_text = json_data["input"]
voice = json_data["voice"] voice = json_data["voice"]
response_format = json_data["response_format"].lower() response_format = json_data.get("response_format", "wav").lower()
speed = json_data["speed"] speed = json_data.get("speed", 1.0)
print(f"[{branding}Debug] Input text: {input_text}") if debug_openai else None print(f"[{branding}Debug] Input text: {input_text}") if debug_openai else None
print(f"[{branding}Debug] Voice: {voice}") if debug_openai else None print(f"[{branding}Debug] Voice: {voice}") if debug_openai else None
print(f"[{branding}Debug] Speed: {speed}") if debug_openai else None print(f"[{branding}Debug] Speed: {speed}") if debug_openai else None
@@ -1594,7 +1594,7 @@ async def apifunction_trigger_analysis(threshold: int = Query(default=98)):
env["PATH"] = os.path.join(venv_path, "bin") + ":" + env["PATH"] env["PATH"] = os.path.join(venv_path, "bin") + ":" + env["PATH"]
ttslist_path = this_dir / output_directory / "ttsList.json" ttslist_path = this_dir / output_directory / "ttsList.json"
wavfile_path = this_dir / output_directory wavfile_path = this_dir / output_directory
subprocess.run(["python", "tts_diff.py", f"--threshold={threshold}", f"--ttslistpath={ttslist_path}", f"--wavfilespath={wavfile_path}"], cwd=this_dir / "system" / "tts_diff", env=env) subprocess.run([sys.executable, "tts_diff.py", f"--threshold={threshold}", f"--ttslistpath={ttslist_path}", f"--wavfilespath={wavfile_path}"], cwd=this_dir / "system" / "tts_diff", env=env)
# Read the analysis summary # Read the analysis summary
try: try:
with open(this_dir / output_directory / "analysis_summary.json", "r") as summary_file: with open(this_dir / output_directory / "analysis_summary.json", "r") as summary_file:
@@ -1613,7 +1613,7 @@ async def apifunction_srt_generation():
env["PATH"] = os.path.join(venv_path, "bin") + ":" + env["PATH"] env["PATH"] = os.path.join(venv_path, "bin") + ":" + env["PATH"]
ttslist_path = this_dir / output_directory / "ttsList.json" ttslist_path = this_dir / output_directory / "ttsList.json"
wavfile_path = this_dir / output_directory wavfile_path = this_dir / output_directory
subprocess.run(["python", "tts_srt.py", f"--ttslistpath={ttslist_path}", f"--wavfilespath={wavfile_path}"], cwd=this_dir / "system" / "tts_srt", env=env) subprocess.run([sys.executable, "tts_srt.py", f"--ttslistpath={ttslist_path}", f"--wavfilespath={wavfile_path}"], cwd=this_dir / "system" / "tts_srt", env=env)
srt_file_path = this_dir / output_directory / "subtitles.srt" srt_file_path = this_dir / output_directory / "subtitles.srt"
if not srt_file_path.exists(): if not srt_file_path.exists():
raise HTTPException(status_code=404, detail="Subtitle file not found.") raise HTTPException(status_code=404, detail="Subtitle file not found.")