用途
Deepgram Text Intelligence(在 SDK 中通过 Analyze* 方法调用,对应 REST 的 /read 端点)用于对已有文本进行情感、摘要、主题和意图分析。
何时使用
- 你已经拥有文本:转录稿、邮件、文档、聊天记录等。
- 你希望进行 REST 风格的分析,而非流式处理。
何时改用其他技能
- 如果来源是音频,且希望在转录过程中进行分析 → 使用 deepgram-dotnet-audio-intelligence。
主要能力
- 情感分析(Sentiment)
- 摘要(Summarize)
- 主题检测(Topics)
- 意图识别(Intents)
- 支持自定义主题与自定义意图
- 支持回调流程
使用方式
安装
dotnet add package Deepgram
认证
using Deepgram;
Library.Initialize();
var client = ClientFactory.CreateAnalyzeClient();
ClientFactory 默认从 DEEPGRAM_API_KEY(或 DEEPGRAM_ACCESS_TOKEN)环境变量读取凭证。显式传入方式:ClientFactory.CreateAnalyzeClient(apiKey: "...", options: ...)。若环境变量和显式凭证均未提供,DeepgramHttpClientOptions 会抛出异常。
快速开始 — 文本
using Deepgram;
using Deepgram.Models.Analyze.v1;
Library.Initialize();
var client = ClientFactory.CreateAnalyzeClient();
var response = await client.AnalyzeText(
new TextSource("Hello, world! This is a sample text for analysis."),
new AnalyzeSchema()
{
Language = "en",
Sentiment = true,
Summarize = true,
Topics = true,
Intents = true,
});
Console.WriteLine(response);
快速开始 — 文件 / URL
var client = ClientFactory.CreateAnalyzeClient();
var fileBytes = File.ReadAllBytes("conversation.txt");
var fileResponse = await client.AnalyzeFile(
fileBytes,
new AnalyzeSchema() { Language = "en", Summarize = true });
var urlResponse = await client.AnalyzeUrl(
new UrlSource("https://example.com/conversation.txt"),
new AnalyzeSchema() { Language = "en", Sentiment = true });
关键参数
AnalyzeSchema:Language、Sentiment、Summarize、Topics、Intents、CustomTopic、CustomTopicMode、CustomIntent、CustomIntentMode、CallBack、CallbackMethod。
输入类型:
- TextSource
- UrlSource
- byte[]
- Stream
API 参考(分层)
仓库内真实来源:
- Deepgram/ClientFactory.cs
- Deepgram/Clients/Analyze/v1/Client.cs
- Deepgram/Models/Analyze/v1/AnalyzeSchema.cs
- Deepgram/Models/Analyze/v1/*.cs
规范 OpenAPI(REST):https://developers.deepgram.com/openapi.yaml
AsyncAPI:本仓库中该产品不适用
Context7:
- 仓库镜像:https://context7.com/deepgram/deepgram-dotnet-sdk
- 文档语料:/llmstxt/developers_deepgram_llms_txt
产品文档:
- https://developers.deepgram.com/reference/text-intelligence/analyze-text
- https://developers.deepgram.com/docs/text-intelligence
注意事项(Gotchas)
- AnalyzeClient 映射到 /read。仓库使用 Analyze* 方法名,而非 Read* 名称。
- 原始字符串使用 AnalyzeText(...)。AnalyzeFile(...) 用于字节/流,即使文件是纯文本。
- 此处 Summarize 是布尔值。不要使用 /listen 摘要中 STT 风格的 "v2" 字符串。
- Language 实际上仅支持英语(受限分析)。schema 文档说明目前仅支持 en。
- 回调流程使用独立方法:AnalyzeTextCallBack、AnalyzeUrlCallBack 或 AnalyzeFileCallBack。
仓库示例文件
- examples/analyze/summary/Program.cs
- examples/analyze/sentiment/Program.cs
- examples/analyze/topic/Program.cs
- examples/analyze/intent/Program.cs
中央产品技能
如需跨语言的 Deepgram 产品知识(整合 API 参考、文档查找器、可运行的聚焦配方、第三方集成示例和 MCP 设置),请安装中央技能:
npx skills add deepgram/skills
本 SDK 附带语言惯用的代码技能;deepgram/skills 提供跨语言产品知识(参见 api、docs、recipes、examples、starters、setup-mcp)。
适用场景
- 对已转录的音频文本进行情感、摘要、主题或意图分析
- 分析邮件、文档、聊天记录等文本内容
- 通过文件或 URL 批量提交文本进行分析
- 需要自定义主题或自定义意图的文本分析
限制
- 受限分析能力目前仅支持英语(en)
- 不适用于音频来源的流式分析(应使用 audio-intelligence 技能)
- 不支持 AsyncAPI
- 回调流程需使用独立方法,而非主分析方法