Move all sensitive data to .env: API keys, IPs, URLs. Add example.env and .gitignore

This commit is contained in:
alex_z46
2026-08-04 19:38:24 +00:00
parent 19d6fcb7a3
commit 3a85da73a2
4 changed files with 49 additions and 23 deletions
+4
View File
@@ -0,0 +1,4 @@
.env
__pycache__/
*.pyc
.dockerenv
+17 -12
View File
@@ -3,6 +3,8 @@
Smart STT Pipeline v3 Smart STT Pipeline v3
T-one (fast) + GigaAM (accurate) + Qwen3.5-4B (punctuation) T-one (fast) + GigaAM (accurate) + Qwen3.5-4B (punctuation)
Auto-selects best STT based on confidence/silence detection. Auto-selects best STT based on confidence/silence detection.
Configuration: all sensitive data loaded from .env file.
""" """
import os import os
@@ -10,22 +12,25 @@ import tempfile
import time import time
import subprocess import subprocess
import re import re
import json
from dotenv import load_dotenv
from fastapi import FastAPI, File, UploadFile, HTTPException from fastapi import FastAPI, File, UploadFile, HTTPException
from pydantic import BaseModel from pydantic import BaseModel
import requests import requests
# === Configuration === # Load .env (skip if not found)
TONE_URL = "http://localhost:8003/transcribe" load_dotenv()
GIGAAM_URL = "http://localhost:8001/transcribe"
QWEN_URL = "http://178.17.143.46:8080/v1/chat/completions" # === Configuration from .env ===
QWEN_URL_FALLBACK = "http://192.168.10.101:8888/v1/chat/completions" TONE_URL = os.getenv("TONE_URL", "http://localhost:8003/transcribe")
QWEN_API_KEY = "f9LHodD0cOIaku1zu7i7vh9KZsb5EelGK4K85k1tJWgzablcQrFw-QNIJaEHHwMb3LZ5k1nd-CKYiYY0F5Yw" GIGAAM_URL = os.getenv("GIGAAM_URL", "http://localhost:8001/transcribe")
QWEN_MODEL = "Qwen3.5-4B-Q5_K_M.gguf" QWEN_URL = os.getenv("QWEN_URL", "http://178.17.143.46:8080/v1/chat/completions")
QWEN_MODEL_FALLBACK = "Qwen3.5-4B-MTP-GGUF" QWEN_URL_FALLBACK = os.getenv("QWEN_URL_FALLBACK", "http://192.168.10.101:8888/v1/chat/completions")
MIN_TEXT_LENGTH = 5 # Minimum chars to consider T-one result valid QWEN_API_KEY = os.getenv("QWEN_API_KEY", "")
SHORT_AUDIO_THRESHOLD = 10 # Seconds: if audio < this, always use GigaAM QWEN_MODEL = os.getenv("QWEN_MODEL", "Qwen3.5-4B-Q5_K_M.gguf")
QWEN_MODEL_FALLBACK = os.getenv("QWEN_MODEL_FALLBACK", "Qwen3.5-4B-MTP-GGUF")
MIN_TEXT_LENGTH = int(os.getenv("MIN_TEXT_LENGTH", "5"))
SHORT_AUDIO_THRESHOLD = int(os.getenv("SHORT_AUDIO_THRESHOLD", "10"))
app = FastAPI(title="Smart STT Pipeline v3", version="3.0.0") app = FastAPI(title="Smart STT Pipeline v3", version="3.0.0")
@@ -37,7 +42,7 @@ class STTResponse(BaseModel):
stt_time_sec: float stt_time_sec: float
punct_time_sec: float punct_time_sec: float
server_used: str server_used: str
stt_engine: str # "t-one", "gigaam", or "both" stt_engine: str # "t-one" or "gigaam"
def convert_to_wav(audio_bytes: bytes) -> str: def convert_to_wav(audio_bytes: bytes) -> str:
+16
View File
@@ -0,0 +1,16 @@
# T-one STT Service
TONE_URL=http://localhost:8003/transcribe
# GigaAM STT Service
GIGAAM_URL=http://localhost:8001/transcribe
# Qwen3.5-4B Punctuation Service
QWEN_URL=http://178.17.143.46:8080/v1/chat/completions
QWEN_URL_FALLBACK=http://192.168.10.101:8888/v1/chat/completions
QWEN_API_KEY=your_qwen_api_key_here
QWEN_MODEL=Qwen3.5-4B-Q5_K_M.gguf
QWEN_MODEL_FALLBACK=Qwen3.5-4B-MTP-GGUF
# Smart Routing Configuration
MIN_TEXT_LENGTH=5
SHORT_AUDIO_THRESHOLD=10
+1
View File
@@ -2,3 +2,4 @@ fastapi==0.115.0
uvicorn==0.32.0 uvicorn==0.32.0
python-multipart==0.0.12 python-multipart==0.0.12
requests==2.34.2 requests==2.34.2
python-dotenv==1.0.1