Deepgram.Read (Deepgram v0.1.0)
View SourceText 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
Analyzes text for intelligence features.
Analyzes text for intents.
Analyzes text for sentiment.
Analyzes text for topics.
Summarizes text.
Summarizes text with a custom model.
Functions
@spec analyze( Deepgram.Client.t(), Deepgram.Types.Read.text_source(), Deepgram.Types.Read.analyze_options() ) :: {:ok, Deepgram.Types.Read.analyze_response()} | {:error, any()}
Analyzes text for intelligence features.
Parameters
client
- ADeepgram.Client
structtext_source
- A map containing the text:%{text: "Analyze this text."}
options
- Optional analysis options (seeDeepgram.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: %{...}}}
@spec analyze_intents( Deepgram.Client.t(), Deepgram.Types.Read.text_source(), Deepgram.Types.Read.analyze_options() ) :: {:ok, Deepgram.Types.Read.analyze_response()} | {:error, any()}
Analyzes text for intents.
Parameters
client
- ADeepgram.Client
structtext_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: %{...}}}}
@spec analyze_sentiment( Deepgram.Client.t(), Deepgram.Types.Read.text_source(), Deepgram.Types.Read.analyze_options() ) :: {:ok, Deepgram.Types.Read.analyze_response()} | {:error, any()}
Analyzes text for sentiment.
Parameters
client
- ADeepgram.Client
structtext_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: %{...}}}}
@spec analyze_topics( Deepgram.Client.t(), Deepgram.Types.Read.text_source(), Deepgram.Types.Read.analyze_options() ) :: {:ok, Deepgram.Types.Read.analyze_response()} | {:error, any()}
Analyzes text for topics.
Parameters
client
- ADeepgram.Client
structtext_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: %{...}}}}
@spec summarize( Deepgram.Client.t(), Deepgram.Types.Read.text_source(), Deepgram.Types.Read.analyze_options() ) :: {:ok, Deepgram.Types.Read.analyze_response()} | {:error, any()}
Summarizes text.
Parameters
client
- ADeepgram.Client
structtext_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: %{...}}}}
@spec summarize_with_model( Deepgram.Client.t(), Deepgram.Types.Read.text_source(), String.t(), Deepgram.Types.Read.analyze_options() ) :: {:ok, Deepgram.Types.Read.analyze_response()} | {:error, any()}
Summarizes text with a custom model.
Parameters
client
- ADeepgram.Client
structtext_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: %{...}}}}