From 4632f8bc1e0318dd9d5057828a2fd8c851efb858 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Sun, 11 Feb 2024 07:52:32 -0700 Subject: more --- api-magic/call_transcript_utils.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 api-magic/call_transcript_utils.py (limited to 'api-magic/call_transcript_utils.py') diff --git a/api-magic/call_transcript_utils.py b/api-magic/call_transcript_utils.py new file mode 100644 index 0000000..992f045 --- /dev/null +++ b/api-magic/call_transcript_utils.py @@ -0,0 +1,32 @@ +import os +from typing import Optional + +CALL_TRANSCRIPTS_DIR = os.path.join(os.path.dirname(__file__), "call_transcripts") + + +def add_transcript(conversation_id: str, transcript: str) -> None: + transcript_path = os.path.join( + CALL_TRANSCRIPTS_DIR, "{}.txt".format(conversation_id) + ) + with open(transcript_path, "a") as f: + f.write(transcript) + + +def get_transcript(conversation_id: str) -> Optional[str]: + transcript_path = os.path.join( + CALL_TRANSCRIPTS_DIR, "{}.txt".format(conversation_id) + ) + if os.path.exists(transcript_path): + with open(transcript_path, "r") as f: + return f.read() + return None + + +def delete_transcript(conversation_id: str) -> bool: + transcript_path = os.path.join( + CALL_TRANSCRIPTS_DIR, "{}.txt".format(conversation_id) + ) + if os.path.exists(transcript_path): + os.remove(transcript_path) + return True + return False \ No newline at end of file -- cgit v1.2.3