-
Notifications
You must be signed in to change notification settings - Fork 0
Back to print to chase down this issue #70
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
base: base-sha/5be14692e15b763bb33cf47eed72651e8f50dddc
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ media/* | |
destinations.csv | ||
.env | ||
venv | ||
.vscode |
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 | ||||||||||||
|
@@ -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. | ||||||||||||
|
@@ -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 | ||||||||||||
|
@@ -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 | ||||||||||||
|
@@ -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 | ||||||||||||
|
||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code_refinement): Maintain use of logging for operational information. Using logging for operational information such as processing files helps in tracking application behavior without cluttering the console output.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment helpful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment type correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the comment area correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this comment become an LLM test? |
||||||||||||
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() | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code_refinement): Consider using logging instead of print for error messages.
Using
logging
allows for better control over logging levels and is more suitable for production environments thanprint
statements.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment helpful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the comment type correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the comment area correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this comment become an LLM test?