Rename OPENAI_API_KEY to HERMES_OPENAI_API_KEY in configuration and codebase for clarity and to avoid conflicts. Update related documentation and error messages to reflect the new key name, ensuring backward compatibility with existing setups.
This commit is contained in:
parent
061fa70907
commit
bdac541d1e
5 changed files with 23 additions and 19 deletions
|
|
@ -47,12 +47,15 @@ def transcribe_audio(file_path: str, model: Optional[str] = None) -> dict:
|
|||
- "transcript" (str): The transcribed text (empty on failure)
|
||||
- "error" (str, optional): Error message if success is False
|
||||
"""
|
||||
api_key = os.getenv("OPENAI_API_KEY")
|
||||
# Use HERMES_OPENAI_API_KEY to avoid interference with the OpenAI SDK's
|
||||
# auto-detection of OPENAI_API_KEY (which would break OpenRouter calls).
|
||||
# Falls back to OPENAI_API_KEY for backward compatibility.
|
||||
api_key = os.getenv("HERMES_OPENAI_API_KEY") or os.getenv("OPENAI_API_KEY")
|
||||
if not api_key:
|
||||
return {
|
||||
"success": False,
|
||||
"transcript": "",
|
||||
"error": "OPENAI_API_KEY not set",
|
||||
"error": "HERMES_OPENAI_API_KEY not set",
|
||||
}
|
||||
|
||||
audio_path = Path(file_path)
|
||||
|
|
@ -100,4 +103,4 @@ def transcribe_audio(file_path: str, model: Optional[str] = None) -> dict:
|
|||
|
||||
def check_stt_requirements() -> bool:
|
||||
"""Check if OpenAI API key is available for speech-to-text."""
|
||||
return bool(os.getenv("OPENAI_API_KEY"))
|
||||
return bool(os.getenv("HERMES_OPENAI_API_KEY") or os.getenv("OPENAI_API_KEY"))
|
||||
|
|
|
|||
|
|
@ -207,9 +207,9 @@ def _generate_openai_tts(text: str, output_path: str, tts_config: Dict[str, Any]
|
|||
Returns:
|
||||
Path to the saved audio file.
|
||||
"""
|
||||
api_key = os.getenv("OPENAI_API_KEY", "")
|
||||
api_key = os.getenv("HERMES_OPENAI_API_KEY") or os.getenv("OPENAI_API_KEY", "")
|
||||
if not api_key:
|
||||
raise ValueError("OPENAI_API_KEY not set. Get one at https://platform.openai.com/api-keys")
|
||||
raise ValueError("HERMES_OPENAI_API_KEY not set. Get one at https://platform.openai.com/api-keys")
|
||||
|
||||
oai_config = tts_config.get("openai", {})
|
||||
model = oai_config.get("model", DEFAULT_OPENAI_MODEL)
|
||||
|
|
@ -389,7 +389,7 @@ def check_tts_requirements() -> bool:
|
|||
return True
|
||||
if _HAS_ELEVENLABS and os.getenv("ELEVENLABS_API_KEY"):
|
||||
return True
|
||||
if _HAS_OPENAI and os.getenv("OPENAI_API_KEY"):
|
||||
if _HAS_OPENAI and (os.getenv("HERMES_OPENAI_API_KEY") or os.getenv("OPENAI_API_KEY")):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
@ -406,7 +406,7 @@ if __name__ == "__main__":
|
|||
print(f" ElevenLabs: {'✅ installed' if _HAS_ELEVENLABS else '❌ not installed (pip install elevenlabs)'}")
|
||||
print(f" API Key: {'✅ set' if os.getenv('ELEVENLABS_API_KEY') else '❌ not set'}")
|
||||
print(f" OpenAI: {'✅ installed' if _HAS_OPENAI else '❌ not installed'}")
|
||||
print(f" API Key: {'✅ set' if os.getenv('OPENAI_API_KEY') else '❌ not set'}")
|
||||
print(f" API Key: {'✅ set' if (os.getenv('HERMES_OPENAI_API_KEY') or os.getenv('OPENAI_API_KEY')) else '❌ not set'}")
|
||||
print(f" ffmpeg: {'✅ found' if _has_ffmpeg() else '❌ not found (needed for Telegram Opus)'}")
|
||||
print(f"\n Output dir: {DEFAULT_OUTPUT_DIR}")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue