Skip to content

Back to print to chase down this issue #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: base-sha/5be14692e15b763bb33cf47eed72651e8f50dddc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ media/*
destinations.csv
.env
venv
.vscode
13 changes: 4 additions & 9 deletions ttt.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python

import json
import logging
import os
import subprocess
import sys
Expand All @@ -15,8 +14,6 @@
import torch
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline

logging.basicConfig(stream=sys.stdout)

# Before we dig in, let's globally set up transformers
# We will load up the model, etc now so we only need to
# use the PIPE constant in the function.
Expand Down Expand Up @@ -71,9 +68,7 @@ def transcribe_whispercpp(calljson, audiofile):
response = requests.post(f"{whisper_url}/inference", files=files)
response.raise_for_status()
except requests.exceptions.RequestException as e:
logging.error(
f"A request error occurred while trying to post to whisper.cpp: {e}"
)
print(f"A request error occurred while trying to post to whisper.cpp: {e}")
raise RuntimeError(
"A request error occurred while trying to post to whisper.cpp."
) from e
Expand Down Expand Up @@ -145,7 +140,7 @@ def transcribe_deepgram(calljson, audiofile):
)
response.raise_for_status()
except requests.exceptions.RequestException as e:
logging.error(f"A request error occurred while trying to post to Deepgram: {e}")
print(f"A request error occurred while trying to post to Deepgram: {e}")
raise RuntimeError(
"A request error occurred while trying to post to Deepgram."
) from e
Expand Down Expand Up @@ -318,15 +313,15 @@ def main():

# If the queue is empty, pause for 5 seconds and then restart polling
if not jsonlist:
logging.debug("Empty queue. Sleep 5 seconds and check again.")
print("Empty queue. Sleep 5 seconds and check again.")
time.sleep(5)
return

for jsonfile in jsonlist:
# Ok, let's grab the first json and pull it out and then the matching wav file
audiofile = Path(jsonfile).with_suffix(".wav")

logging.info(f"Processing: {audiofile}")
print(f"Processing: {audiofile}")

# Now load the actual json data into calljson
calljson = jsonfile.read_text()
Expand Down