Skip to content

Commit

Permalink
Docker configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
etown committed Feb 16, 2024
1 parent d605764 commit 2ed6849
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/captures/
/clients/
/docs/
local.yaml
db.sqlite3

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ services:
backend:
image: etown/untitledai:latest
environment:
- UNTITLEDAI_TRANSCRIPTION_HF_TOKEN=${UNTITLEDAI_TRANSCRIPTION_HF_TOKEN}
- UNTITLEDAI_ASYNC_WHISPER_HF_TOKEN=${UNTITLEDAI_ASYNC_WHISPER_HF_TOKEN}
- UNTITLEDAI_USER_CLIENT_TOKEN=${UNTITLEDAI_USER_CLIENT_TOKEN:-change_me}
- UNTITLEDAI_LLM_API_BASE_URL=${UNTITLEDAI_LLM_API_BASE_URL:-http://host.docker.internal:11434}
- OMP_NUM_THREADS=1

shm_size: 3g
ports:
Expand All @@ -21,8 +22,5 @@ services:
- UNTITLEDAI_USER_CLIENT_TOKEN=${UNTITLEDAI_USER_CLIENT_TOKEN:-change_me}
ports:
- "3000:3000"
volumes:
- ./clients/web:/app
depends_on:
- backend

Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ class AsyncWhisperTranscriptionServer:
def __init__(self, config: AsyncWhisperConfiguration):
self._config = config
self.app = FastAPI()
self._transcription_model, self._diarize_model, self._verification_model = self._load_models()
self._transcription_model, self._diarize_model, self._verification_model, self._alignment_model, self._alignment_metadata = self._load_models()
self._setup_routes()

def _load_models(self):
logger.info(f"Transcription model: {self._config.model}")
transcription_model = whisperx.load_model(self._config.model, self._config.device, compute_type=self._config.compute_type)
diarize_model = whisperx.DiarizationPipeline(use_auth_token=self._config.hf_token, device=self._config.device)
verification_model = SpeakerRecognition.from_hparams(source=self._config.verification_model_source, savedir=self._config.verification_model_savedir, run_opts={"device": self._config.device})
return transcription_model, diarize_model, verification_model
alignment_model, alignment_metadata = whisperx.load_align_model(language_code="en", device=self._config.device)
return transcription_model, diarize_model, verification_model, alignment_model, alignment_metadata

def _setup_routes(self):
# Main endpoint takes a file path and returns a transcription response
Expand Down Expand Up @@ -84,8 +85,7 @@ async def _transcribe_audio(self, main_audio_filepath, voice_sample_filepath=Non
logger.info(f"Initial transcription complete. Total segments: {len(initial_transcription)}")

# Align whisper output
model_a, metadata = whisperx.load_align_model(language_code=result["language"], device=self._config.device)
result = whisperx.align(initial_transcription, model_a, metadata, audio, device=self._config.device, return_char_alignments=False)
result = whisperx.align(initial_transcription, self._alignment_model, self._alignment_metadata, audio, device=self._config.device, return_char_alignments=False)

# Speaker diarization
diarize_segments = self._diarize_model(audio)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ async def transcribe_audio(self, main_audio_filepath, voice_sample_filepath=None
url = f"http://{self._config.host}:{self._config.port}/transcribe/"

try:
logger.info(f"Sending request to local async whisper server at {url}...")
response = await self.http_client.post(url, json=payload)
response.raise_for_status()
response_string = response.text

logger.info(f"Sending request to local async whisper server at {url}...")
transcript_response = TranscriptionResponse.model_validate_json(response_string)
utterances = []
for whisper_utterance in transcript_response.utterances:
Expand Down

0 comments on commit 2ed6849

Please sign in to comment.