Deepgram.Read (Deepgram v0.1.0)

View Source

Text Intelligence services for the Deepgram API.

The Deepgram.Read module provides advanced text analysis capabilities through Deepgram's Text Intelligence API. It enables developers to extract meaningful insights from text data through various analysis features.

Key Features

  • Sentiment Analysis - Determine emotional tone and sentiment polarity in text
  • Topic Detection - Identify key topics and themes within content
  • Intent Recognition - Understand user goals and intentions from text
  • Summarization - Generate concise summaries of longer text content
  • Entity Recognition - Identify and extract named entities from text
  • Combined Analysis - Run multiple analysis types in a single API call
  • Custom Model Support - Use specialized models for different analysis needs

Authentication

All functions in this module require a properly configured Deepgram.Client struct, which can be created using Deepgram.new/1.

Example:

# Create client with API key
client = Deepgram.new(api_key: System.get_env("DEEPGRAM_API_KEY"))

# Or with OAuth token
client = Deepgram.new(token: "your-oauth-token")

Basic Usage

Analyze text for sentiment:

client = Deepgram.new(api_key: System.get_env("DEEPGRAM_API_KEY"))
text_source = %{text: "I love this product! It's amazing and works perfectly."}
{:ok, response} = Deepgram.Read.analyze_sentiment(client, text_source)

Analyze text for topics:

text_source = %{text: "Let's discuss machine learning and artificial intelligence."}
{:ok, response} = Deepgram.Read.analyze_topics(client, text_source)

Summarize text content:

long_text = %{text: "Long article or document content that needs to be summarized..."}
{:ok, response} = Deepgram.Read.summarize(client, long_text)

Advanced Usage

Perform multiple analysis types in a single call:

text_source = %{text: "I really enjoyed the customer service. The representative was very helpful."}
options = %{
  model: "nova-2", 
  sentiment: true,
  topics: true,
  intents: true
}
{:ok, response} = Deepgram.Read.analyze(client, text_source, options)

Use a specific model for summarization:

{:ok, response} = Deepgram.Read.summarize_with_model(client, long_text, "nova-2")

Summary

Functions

analyze(client, text_source, options \\ %{})

Analyzes text for intelligence features.

Parameters

  • client - A Deepgram.Client struct
  • text_source - A map containing the text: %{text: "Analyze this text."}
  • options - Optional analysis options (see Deepgram.Types.Read.analyze_options/0)

Examples

iex> client = Deepgram.new(api_key: "your-api-key")
iex> text_source = %{text: "I love this product! It's amazing and works perfectly."}
iex> options = %{model: "nova-2", sentiment: true, topics: true}
iex> {:ok, response} = Deepgram.Read.analyze(client, text_source, options)
{:ok, %{metadata: %{...}, results: %{...}}}

analyze_intents(client, text_source, options \\ %{})

Analyzes text for intents.

Parameters

  • client - A Deepgram.Client struct
  • text_source - A map containing the text: %{text: "Analyze this text."}
  • options - Optional analysis options

Examples

iex> client = Deepgram.new(api_key: "your-api-key")
iex> text_source = %{text: "I want to cancel my subscription."}
iex> {:ok, response} = Deepgram.Read.analyze_intents(client, text_source)
{:ok, %{metadata: %{...}, results: %{intents: %{...}}}}

analyze_sentiment(client, text_source, options \\ %{})

Analyzes text for sentiment.

Parameters

  • client - A Deepgram.Client struct
  • text_source - A map containing the text: %{text: "Analyze this text."}
  • options - Optional analysis options

Examples

iex> client = Deepgram.new(api_key: "your-api-key")
iex> text_source = %{text: "I love this product!"}
iex> {:ok, response} = Deepgram.Read.analyze_sentiment(client, text_source)
{:ok, %{metadata: %{...}, results: %{sentiments: %{...}}}}

analyze_topics(client, text_source, options \\ %{})

Analyzes text for topics.

Parameters

  • client - A Deepgram.Client struct
  • text_source - A map containing the text: %{text: "Analyze this text."}
  • options - Optional analysis options

Examples

iex> client = Deepgram.new(api_key: "your-api-key")
iex> text_source = %{text: "Let's discuss machine learning and artificial intelligence."}
iex> {:ok, response} = Deepgram.Read.analyze_topics(client, text_source)
{:ok, %{metadata: %{...}, results: %{topics: %{...}}}}

summarize(client, text_source, options \\ %{})

Summarizes text.

Parameters

  • client - A Deepgram.Client struct
  • text_source - A map containing the text: %{text: "Text to summarize."}
  • options - Optional analysis options

Examples

iex> client = Deepgram.new(api_key: "your-api-key")
iex> text_source = %{text: "Long text that needs to be summarized..."}
iex> {:ok, response} = Deepgram.Read.summarize(client, text_source)
{:ok, %{metadata: %{...}, results: %{summary: %{...}}}}

summarize_with_model(client, text_source, model, options \\ %{})

Summarizes text with a custom model.

Parameters

  • client - A Deepgram.Client struct
  • text_source - A map containing the text: %{text: "Text to summarize."}
  • model - Summary model to use (e.g., "nova-2")
  • options - Optional analysis options

Examples

iex> client = Deepgram.new(api_key: "your-api-key")
iex> text_source = %{text: "Long text that needs to be summarized..."}
iex> {:ok, response} = Deepgram.Read.summarize_with_model(client, text_source, "nova-2")
{:ok, %{metadata: %{...}, results: %{summary: %{...}}}}