SuperAPI AI 工具集

deepgram-dotnet-audio-intelligence

编程与开发

查看项目

更新于 10-16 06:00

技能介绍

用途

本技能用于在 Deepgram .NET SDK 仓库中编写或审查 C# 代码时,为语音转文字(Speech-to-Text)请求启用 Deepgram 音频智能(Audio Intelligence)叠加功能。音频分析建立在同一套 STT 客户端之上,通过 schema 属性开启相应特性。

适用场景:你有一段音频,希望在一次请求中同时获得转录文本和分析结果。REST 是摘要、主题、意图、情感和语言检测的主要路径。

以下情况应使用其他技能:

  • 只需要转录文本 → deepgram-dotnet-speech-to-text。
  • 已有文本并想使用 /read → deepgram-dotnet-text-intelligence。

主要能力

音频智能特性在 REST 与 WebSocket 两条路径上的可用性不同:

特性 REST (PreRecordedSchema) WebSocket (LiveSchema)
Diarize(说话人分离) 支持 支持
Redact(脱敏) 支持 支持
DetectEntities(实体识别) 支持 未在 LiveSchema 中暴露
Summarize(摘要) 支持(字符串) 不支持
Topics / Intents / Sentiment(主题/意图/情感) 支持 不支持
DetectLanguage(语言检测) 支持 不支持
CustomTopic / CustomIntent(自定义主题/意图) 支持 不支持

使用方式

认证

安装包:

dotnet add package Deepgram

初始化:

using Deepgram;

Library.Initialize();
var client = ClientFactory.CreateListenRESTClient();

ClientFactory 默认从 DEEPGRAM_API_KEY(或 DEEPGRAM_ACCESS_TOKEN)环境变量读取凭据。如需显式传入,可使用 ClientFactory.CreateListenRESTClient(apiKey: "...", options: ...) / CreateListenWebSocketClient(apiKey: "...", options: ...)。若既未提供环境变量也未提供显式凭据,DeepgramHttpClientOptions / DeepgramWsClientOptions 会抛出异常。

快速上手 — REST

using Deepgram.Models.Listen.v1.REST;

var client = ClientFactory.CreateListenRESTClient();

var response = await client.TranscribeUrl(
    new UrlSource("https://dpgr.am/spacewalk.wav"),
    new PreRecordedSchema()
    {
        Model = "nova-3",
        Punctuate = true,
        SmartFormat = true,
        Diarize = true,
        Summarize = "v2",
        Topics = true,
        Intents = true,
        Sentiment = true,
        DetectLanguage = true,
        DetectEntities = true,
        Redact = new List<string> { "pii", "numbers" },
        Language = "en",
    });

Console.WriteLine(response.Results.Channels[0].Alternatives[0].Transcript);
Console.WriteLine(response.Results.Summary);

快速上手 — 实时子集

using Deepgram.Models.Listen.v2.WebSocket;

var liveClient = ClientFactory.CreateListenWebSocketClient();

await liveClient.Subscribe(new EventHandler<ResultResponse>((sender, e) =>
{
    Console.WriteLine(e.Channel.Alternatives[0].Transcript);
}));

await liveClient.Connect(new LiveSchema()
{
    Model = "nova-3",
    Diarize = true,
    Redact = new List<string> { "pii" },
    Encoding = "linear16",
    SampleRate = 16000,
});

关键参数

REST(PreRecordedSchema):Summarize、Topics、Intents、Sentiment、DetectLanguage、DetectEntities、CustomTopic、CustomTopicMode、CustomIntent、CustomIntentMode、Diarize、DiarizeVersion、DiarizeModel、Redact、Utterances,以及常规 STT 参数。

Live(LiveSchema):Diarize、Redact、UtteranceEnd、VadEvents、Punctuate、SmartFormat,以及常规流式 STT 设置。

API 参考(分层)

仓库内权威来源:

  • Deepgram/Models/Listen/v1/REST/PreRecordedSchema.cs
  • Deepgram/Models/Listen/v2/WebSocket/LiveSchema.cs
  • Deepgram/Clients/Listen/v1/REST/Client.cs
  • Deepgram/Clients/Listen/v2/WebSocket/Client.cs

规范 OpenAPI(REST):https://developers.deepgram.com/openapi.yaml

规范 AsyncAPI(流式 / WSS):https://developers.deepgram.com/asyncapi.yaml

Context7:

  • 仓库镜像:https://context7.com/deepgram/deepgram-dotnet-sdk
  • 文档语料:/llmstxt/developers_deepgram_llms_txt

产品文档:

  • https://developers.deepgram.com/docs/stt-intelligence-feature-overview
  • https://developers.deepgram.com/docs/summarization
  • https://developers.deepgram.com/docs/topic-detection
  • https://developers.deepgram.com/docs/intent-recognition
  • https://developers.deepgram.com/docs/sentiment-analysis
  • https://developers.deepgram.com/docs/language-detection
  • https://developers.deepgram.com/docs/redaction
  • https://developers.deepgram.com/docs/diarization

适用场景

  • 需要一次请求同时获得转录文本与摘要、主题、意图、情感、语言检测等分析结果。
  • 需要在实时流式场景中使用说话人分离或脱敏。
  • 需要按仓库内示例文件快速上手:examples/speech-to-text/rest/summary/Program.cs、sentiment/Program.cs、topic/Program.cs、intent/Program.cs、file/Program.cs。

限制与注意事项

  • STT 上的 Summarize 是字符串。应使用 Summarize = "v2",而不是 true。
  • 大多数智能叠加功能仅限 REST。实时 schema 不暴露摘要/主题/意图/情感/语言选项。
  • Redact 是 List<string>。本 SDK 不暴露 Python 风格的字符串或数组联合类型。
  • 自定义主题和意图需要模式。需设置 CustomTopicMode / CustomIntentMode,否则模型行为可能与预期不符。
  • 说话人分离在两条路径均可用,但事件结构不同。实时结果在流式响应中逐词暴露说话人数据。

跨语言产品技能

如需跨语言的 Deepgram 产品知识(整合 API 参考、文档查找器、可运行配方、第三方集成示例和 MCP 设置),可安装中央技能:

npx skills add deepgram/skills

本 SDK 提供语言惯用的代码技能;deepgram/skills 提供跨语言产品知识(见 api、docs、recipes、examples、starters、setup-mcp)。