Skip to content

Commit 8ff0bce

Browse files
committed
refactor: Refactor file writing functionality in transcription module
- 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
1 parent 9413b3d commit 8ff0bce

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

transcribe_me/audio/transcription.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,29 +104,24 @@ def transcribe_with_assemblyai(
104104
with open(f"{base_name}_speakers.txt", "w", encoding="utf-8") as file:
105105
for utterance in transcript.utterances:
106106
file.write(f"Speaker {utterance.speaker}: {utterance.text}\n")
107-
108-
# Auto Highlights
109-
with open(f"{base_name}_auto_highlights.txt", "w", encoding="utf-8") as file:
110-
for highlight in transcript.auto_highlights_result.results:
111-
file.write(f"{highlight.text}\n")
112-
113107
# Summary
114108
with open(f"{base_name}_summary.txt", "w", encoding="utf-8") as file:
115109
file.write(transcript.summary)
116110

117111
# Sentiment Analysis
118-
if transcript.sentiment_analysis:
119-
with open(f"{base_name}_sentiment.txt", "w", encoding="utf-8") as file:
120-
for result in transcript.sentiment_analysis:
121-
file.write(f"Text: {result.text}\n")
122-
file.write(f"Sentiment: {result.sentiment}\n")
123-
file.write(f"Confidence: {result.confidence}\n")
124-
file.write(f"Timestamp: {result.start} - {result.end}\n\n")
112+
with open(f"{base_name}_sentiment.txt", "w", encoding="utf-8") as file:
113+
for result in transcript.sentiment_analysis:
114+
file.write(f"Text: {result.text}\n")
115+
file.write(f"Sentiment: {result.sentiment}\n")
116+
file.write(f"Confidence: {result.confidence}\n")
117+
file.write(f"Timestamp: {result.start} - {result.end}\n\n")
125118

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

131126
# Topic Detection
132127
if transcript.iab_categories:

0 commit comments

Comments
 (0)