What is the current behavior?
Now when getting a response from the Python SDK, the captions converter will not work. The response type that comes back from the SDK is a PrerecordedResponse type. This needs to be converted to a dictionary for the captions to work. This can be done by the user with this:
transcription = DeepgramConverter(json.loads(response.to_json()))
However, we need to fix the captions package to be able to handle that type and convert it to a dictionary.
Steps to reproduce
In the following code, change json.loads(response.to_json()
to response or response.to_json() (remove the json.loads)
import json
from deepgram import (
DeepgramClient,
PrerecordedOptions,
)
from deepgram_captions import DeepgramConverter, srt
AUDIO_URL = {
"url": "https://dpgr.am/spacewalk.wav"
}
deepgram = DeepgramClient("")
options = PrerecordedOptions(
model="nova",
smart_format=True,
utterances=True
)
response = deepgram.listen.prerecorded.v("1").transcribe_url(AUDIO_URL, options)
if isinstance(json.loads(response.to_json()), dict):
print("Response is a dictionary.")
else:
print("Response is not a dictionary.")
transcription = DeepgramConverter(json.loads(response.to_json()))
captions = srt(transcription)
print(captions)
Expected behavior
Expect to not have to add json.loads
OR MAYBE JUST UPDATE THE README TO INFORM USERS OF HOW TO DO THIS
See discord conversation where this was originally raised: https://discord.com/channels/1108042150941294664/1204723190044295238/1204723190044295238