Skip to content

Commit

Permalink
refactor: Refactor file writing functionality in transcription module
Browse files Browse the repository at this point in the history
- Improve file writing in transcription module
- Do not automatically write highlight files
- Include all results in sentiment analysis file writing
- Add count and rank information to key phrase file writing
  • Loading branch information
johnnyhuy committed Oct 20, 2024
1 parent 9413b3d commit 8ff0bce
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions transcribe_me/audio/transcription.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,29 +104,24 @@ def transcribe_with_assemblyai(
with open(f"{base_name}_speakers.txt", "w", encoding="utf-8") as file:
for utterance in transcript.utterances:
file.write(f"Speaker {utterance.speaker}: {utterance.text}\n")

# Auto Highlights
with open(f"{base_name}_auto_highlights.txt", "w", encoding="utf-8") as file:
for highlight in transcript.auto_highlights_result.results:
file.write(f"{highlight.text}\n")

# Summary
with open(f"{base_name}_summary.txt", "w", encoding="utf-8") as file:
file.write(transcript.summary)

# Sentiment Analysis
if transcript.sentiment_analysis:
with open(f"{base_name}_sentiment.txt", "w", encoding="utf-8") as file:
for result in transcript.sentiment_analysis:
file.write(f"Text: {result.text}\n")
file.write(f"Sentiment: {result.sentiment}\n")
file.write(f"Confidence: {result.confidence}\n")
file.write(f"Timestamp: {result.start} - {result.end}\n\n")
with open(f"{base_name}_sentiment.txt", "w", encoding="utf-8") as file:
for result in transcript.sentiment_analysis:
file.write(f"Text: {result.text}\n")
file.write(f"Sentiment: {result.sentiment}\n")
file.write(f"Confidence: {result.confidence}\n")
file.write(f"Timestamp: {result.start} - {result.end}\n\n")

# Key Phrases
with open(f"{base_name}_key_phrases.txt", "w", encoding="utf-8") as file:
for phrase in transcript.auto_highlights_result.results:
file.write(f"{phrase.text}\n")
file.write(f"Highlight: {phrase.text}\n")
file.write(f"Count: {phrase.count}\n")
file.write(f"Rank: {phrase.rank}\n")

# Topic Detection
if transcript.iab_categories:
Expand Down

0 comments on commit 8ff0bce

Please sign in to comment.