Find transcript on Deepgram site #130
-
I don't know anything about coding (have forgotten Fortran :) ). I want to use Deepgram to simply create transcriptions from an online video course (have permission). I created the transcription but had to take time away and got logged off. When I went back I can see that the transcription was done as per below, but I can't find where to download it as a document. Can anyone help? Have not been able to get an answer from support. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @bhaviland, Deepgram does not store transcriptions. You will need to have your code handle the response or provide a callback url to handle the response. |
Beta Was this translation helpful? Give feedback.
-
Hi Scott,
Appreciate your response and the coding tips. I kept running the transcript and for some reason the last time I was able to use the copy option to get the document. So I'm OK for now but I will save your info in case I need to do this in the future.
Cheers,
Brian
…________________________________
From: Scott Stephenson ***@***.***>
Sent: Monday, May 1, 2023 5:26 AM
To: deepgram/community ***@***.***>
Cc: bhaviland ***@***.***>; Mention ***@***.***>
Subject: Re: [deepgram/community] Find transcript on Deepgram site (Discussion #130)
Firstly, I understand that learning to code can seem daunting especially if you've been away from it for a while. But it probably isn’t as hard as it seems! In fact, Python is a great language to start with. It's simple and readable, yet very powerful. The language is designed to be easy to understand and write, so you might find that it's easier to pick up than you expect or remember for FORTRAN days.
Below, I have provided two Python scripts:
1. The first script is to upload a local audio file to Deepgram and save the transcript as a text file in the same location as the original audio file.
2. The second script is to generate an SRT file for closed captioning on a web video from the Deepgram transcript.
Here we go:
1. Upload a local audio file and save the transcript:
import requests
import json
# Replace with your Deepgram API Key
api_key = "YOUR_DEEPGRAM_API_KEY"
# Endpoint for Deepgram's transcription service
url = "https://api.deepgram.com/v1/listen"
# Headers for the request
headers = {
"Authorization": "Token " + api_key
}
# Path to your local audio file
audio_file_path = "/path/to/your/audio/file.wav"
# Open the audio file in read-bytes mode
with open(audio_file_path, "rb") as audio_file:
# Send the request to Deepgram
response = requests.post(url, headers=headers, data=audio_file)
# Parse the response from Deepgram
data = json.loads(response.text)
# Save the transcript to a .txt file
with open(audio_file_path + ".txt", "w") as text_file:
text_file.write(data["results"]["channels"][0]["alternatives"][0]["transcript"])
2. Generate an SRT file for closed captioning from the Deepgram transcript:
import requests
import json
import textwrap
# Replace with your Deepgram API Key
api_key = "YOUR_DEEPGRAM_API_KEY"
# Endpoint for Deepgram's transcription service
url = "https://api.deepgram.com/v1/listen"
# Headers for the request
headers = {
"Authorization": "Token " + api_key
}
# Path to your local audio file
audio_file_path = "/path/to/your/audio/file.wav"
# Open the audio file in read-bytes mode
with open(audio_file_path, "rb") as audio_file:
# Send the request to Deepgram
response = requests.post(url, headers=headers, data=audio_file)
# Parse the response from Deepgram
data = json.loads(response.text)
# Save the transcript to a .srt file
with open(audio_file_path + ".srt", "w") as srt_file:
word_info = data["results"]["channels"][0]["alternatives"][0]["words"]
i = 1
for start_index in range(0, len(word_info), 2):
start_time = word_info[start_index]["start"]
if start_index + 1 < len(word_info):
end_time = word_info[start_index + 1]["end"]
text = word_info[start_index]["word"] + " " + word_info[start_index + 1]["word"]
else:
end_time = word_info[start_index]["end"]
text = word_info[start_index]["word"]
start_min, start_sec = divmod(start_time, 60)
end_min, end_sec = divmod(end_time, 60)
start_hours, start_min = divmod(start_min, 60
end_hours, end_min = divmod(end_min, 60)
caption = "{}\n{:02}:{:02}:{:02},000 --> {:02}:{:02}:{:02},000\n{}\n\n".format(
i, int(start_hours), int(start_min), int(start_sec), int(end_hours), int(end_min), int(end_sec), text)
srt_file.write(caption)
i += 1
Please replace "YOUR_DEEPGRAM_API_KEY" with your actual Deepgram API key and /path/to/your/audio/file.wav with the actual path of the audio file you want to transcribe on your local machine.
You can run these scripts in any Python environment. If you don't have one installed, you might want to try downloading Anaconda Individual Edition<https://www.anaconda.com/products/individual>. It's free and comes with a lot of useful tools for Python programming.
Once you've installed a Python environment, you can save these scripts as .py files (for example, transcribe_audio.py and generate_srt.py), and then run them from the command line by navigating to the directory where you saved them and typing python transcribe_audio.py or python generate_srt.py. Alternatively, you can run them directly in your Python environment's script editor.
I hope this helps! Don't hesitate to ask if you have any questions. Learning to code again is a journey. Take it one step at a time and it won’t be long til you'll be writing your own scripts.
—
Reply to this email directly, view it on GitHub<#130 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AVPEGYIZTQHDR6V5INBEA2DXD6FUXANCNFSM6AAAAAAXJ5UCMY>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Hi @bhaviland,
Deepgram does not store transcriptions. You will need to have your code handle the response or provide a callback url to handle the response.