Skip to content

Commit

Permalink
Updated dependencies, made whisper and audioshake work in parallel to…
Browse files Browse the repository at this point in the history
… output both, improved file naming consistency, etc.
  • Loading branch information
beveradb committed Dec 27, 2024
1 parent 4757ac1 commit dae1e32
Show file tree
Hide file tree
Showing 3 changed files with 543 additions and 543 deletions.
16 changes: 14 additions & 2 deletions lyrics_transcriber/audioshake_transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ def __init__(self, api_token, logger, output_prefix):
self.logger = logger
self.output_prefix = output_prefix

def transcribe(self, audio_filepath):
self.logger.info(f"Transcribing {audio_filepath} using AudioShake API")
def start_transcription(self, audio_filepath):
"""Starts the transcription job and returns the job ID without waiting for completion"""
self.logger.info(f"Starting transcription for {audio_filepath} using AudioShake API")

# Step 1: Upload the audio file
asset_id = self._upload_file(audio_filepath)
Expand All @@ -22,13 +23,24 @@ def transcribe(self, audio_filepath):
job_id = self._create_job(asset_id)
self.logger.info(f"Job created successfully. Job ID: {job_id}")

return job_id

def get_transcription_result(self, job_id):
"""Gets the results for a previously started job"""
self.logger.info(f"Getting results for job ID: {job_id}")

# Step 3: Wait for the job to complete and get the results
result = self._get_job_result(job_id)
self.logger.info(f"Job completed. Processing results...")

# Step 4: Process the result and return in the required format
return self._process_result(result)

def transcribe(self, audio_filepath):
"""Original method now just combines the two steps"""
job_id = self.start_transcription(audio_filepath)
return self.get_transcription_result(job_id)

def _upload_file(self, filepath):
self.logger.info(f"Uploading {filepath} to AudioShake")
url = f"{self.base_url}/upload"
Expand Down
Loading

0 comments on commit dae1e32

Please sign in to comment.