Skip to content

Instantly share code, notes, and snippets.

@iCUE-Solutions
Last active June 18, 2024 14:42
Show Gist options
  • Save iCUE-Solutions/6acb93b65406d008e926919901319ad2 to your computer and use it in GitHub Desktop.
Save iCUE-Solutions/6acb93b65406d008e926919901319ad2 to your computer and use it in GitHub Desktop.
deepgramm (text to text)
from deepgram import DeepgramClient, PrerecordedOptions, AnalyzeOptions
DEEPGRAM_API_KEY = "c54089a7b3d72c96a9f880d9e3a00aaf26322021"
TEXT = {
"buffer": "Enter your text here."
}
def dg_ttt():
try:
deepgram = DeepgramClient(DEEPGRAM_API_KEY)
options = AnalyzeOptions(
language="en",
summarize="v2",
topics=True,
custom_topic=["math", "squares"],
intents=True,
custom_intent=["calculate squares"],
sentiment=True,
)
response = deepgram.read.analyze.v("1").analyze_text(TEXT, options)
print(response.to_json(indent=4))
except Exception as e:
print(f"Exception: {e}")
if __name__ == "__main__":
main()
AUDIO_URL = {
"url": "https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav"
}
def dg_trans():
try:
deepgram = DeepgramClient(DEEPGRAM_API_KEY)
options = PrerecordedOptions(
model="nova-2",
language="en-US",
summarize="v2",
topics=True,
intents=True,
custom_intent=["teach math", "teach multiplication"],
smart_format=True,
paragraphs=True,
utterances=True,
search=["the quick brown fox jumps over the lazy dog", "listen"],
keywords=["squares:2", "listen:1"],
diarize=True,
sentiment=True,
)
response = deepgram.listen.prerecorded.v("1").transcribe_url(AUDIO_URL, options)
print(response.to_json(indent=4))
except Exception as e:
print(f"Exception: {e}")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment