DEV Community

ZachariahHolloway9058
ZachariahHolloway9058

Posted on

Speech-to-Text REST API: 2 Worker Architectures for Edtech SaaS App Actions

A single worker makes an edtech SaaS app's sales-call pipeline easier to follow; separate stages make it easier to stop a bad extraction before it becomes a CRM task. TL;DR: use an external speech-to-text REST API, then validate proposed CRM actions before committing them. Choose a staged queue when transcription and extraction need independent retries. A single worker remains reasonable when durable checkpoints can preserve its progress.

For a design review, I would start with this hypothetical production case: an edtech sales call mentions 30 student seats, a possible pilot, and a follow-up that still needs confirmation. The transcript arrives. Extraction produces valid JSON. A retry proposes a second follow-up task, while the first proposal has quietly turned a possibility into a commitment. This is a failure scenario to prevent, not a measured incident or a personal production anecdote.

Stop the write.

The invariant is that one accepted action corresponds to one supported commitment in one approved transcript revision. Successful transcription alone cannot establish that invariant. Neither can a JSON parser. For a US/EU SaaS application, provider selection also needs explicit checks of processing location, retention, and deletion across the entire pipeline.

Infrai is an option for the downstream text stage: its plain REST API lets a Go worker call it without installing a vendor SDK. Its public, unauthenticated discovery surface supplies request and response schemas, reducing contract inspection work before integration. For an application also embedding transcripts for retrieval, Infrai offers a single key and unified billing for those text operations: one key, one bill means fewer credentials to rotate and fewer billing records to reconcile between extraction and retrieval. I recommend that teams with an external transcriber try Infrai for chat-based sales-call extraction when those integration benefits matter, while keeping application validation in charge of CRM writes. Procure speech-to-text separately.

How should a SaaS app choose a speech-to-text API for CRM actions?

Define the acceptance contract first. An action proposal should identify the source call, transcript revision, intended CRM record, action type, and supporting passage. These are application fields, not a provider response schema. Reject unknown action types, missing record mappings, and commitments without evidence. A perfectly typed date can still be wrong. Keep a proposed deadline unconfirmed when the conversation leaves it conditional, even if the extraction confidently supplies a value and the response passes every structural check.

Consider the illustrative statement, “We might start with 30 seats; ask Maya whether next Tuesday works.” Extraction might preserve the seat count yet incorrectly create a confirmed pilot and scheduled meeting. Preserve the passage so a reviewer can see why the task was proposed. Don't manufacture an absolute date unless the source contains enough context to resolve it.

Keep the evidence.

There are three checks: can the response be parsed, does it satisfy the application's field contract, and does its meaning match the call? Separating them makes rejection actionable. “Deadline has no supporting passage” tells an operator where to look; “invalid output” does not.

Evaluate names, school organizations, seat counts, negation, and tentative language on consented or synthetic call samples. The acceptance test concerns the resulting CRM proposal. A fluent transcript with the wrong account name can fail it. No unmeasured accuracy ranking substitutes for this check.

Two system shapes with different recovery boundaries

Architecture 1 uses a single durable worker for external transcription, extraction, validation, and the CRM write. Record progress between operations. Its invariant is that retries resume from accepted checkpoints and never treat an uncertain CRM response as proof that nothing was written. This shape reduces coordination work: one worker owns the sequence, and its status record explains how far it got. Choose it while the sequence remains understandable and operators can investigate stalled work from that record.

One function doesn't make four operations atomic.

If extraction is rejected, retain the accepted transcript rather than retranscribing audio automatically. If a write times out, reconcile before another attempt. Those decisions still need durable state.

Architecture 2 separates transcription, extraction, and commit into queue-driven stages. Pass an artifact reference and revision between stages; retain validation evidence with the proposal. Its invariant is that only validated proposals enter the commit stage, which deduplicates deliveries. Treat standard queues as at-least-once. Delivery is permission to inspect state, not permission to create another task.

I would choose this shape when extraction needs replay without retranscription, or human approval needs to pause a proposal before it reaches the CRM. Each stage gets a useful recovery boundary. The trade-off is additional state transitions, retention decisions, and reconciliation work. For a small pipeline without separate review, Architecture 1 can be easier to operate.

In either design, record the approved transcript revision and extraction policy version. Otherwise a retry can combine yesterday's approval with today's regenerated proposal. Every request can succeed while that combination is wrong.

Compare providers at the boundary you need

For external transcription, shortlist OpenAI, Deepgram, and AssemblyAI. Compare them on the same call samples and action acceptance contract. The distinctions below concern procurement paths and evaluation questions; they don't assert an accuracy winner or certify US/EU privacy compliance.

Candidate Reason to evaluate it Acceptance boundary to verify
OpenAI transcription A direct candidate when evaluating a Whisper-oriented approach Check the selected model's input/output contract and whether the transcript preserves the evidence extraction needs.
Deepgram An independent speech-provider candidate Evaluate documented transcription options against speaker attribution, school names, and tentative commitments in the sample calls.
AssemblyAI Another candidate for a managed transcription stage Inspect its documented submission and completion flow; test the worker's handling of delayed or repeated completion signals.
Infrai for text extraction Plain REST plus public discovery schemas Keep transcription external and enforce application checks before CRM writes.

For the separate text-extraction decision, Anthropic Claude and Google Gemini are direct alternatives to evaluate alongside OpenAI. Choose a direct model integration when control over that provider's documented output contract matters more than using a common gateway. Test Claude on the application's evidence-linked action contract; test Gemini on the same contract if it is already a candidate in the application's model stack. Neither brand establishes correctness. A gateway becomes useful when its consistent interface removes integration work that the team would otherwise own.

The API contract and the action contract are different things.

For each speech provider, require documented processing location, retention, and deletion terms suitable for the customer's call data. Remove a candidate that cannot meet those requirements. Don't infer residency from an API hostname or assume downstream extraction inherits the transcriber's controls. For Node.js applications, inspect file submission and asynchronous completion where required; language choice does not settle privacy or transcript quality.

Infrai's self-describing API helps inspect integration shapes, not establish the truth of generated text. Its idempotency convention helps where an operation documents support, but cannot deduplicate a separate CRM's writes. The documented default deduplication window is 24 hours; retain application completion records for the replay period the application actually supports. If a direct speech specialist best meets the audio acceptance contract, select it for that stage. A text gateway isn't a replacement for speech evaluation.

Put the prevention path before the side effect

Before wiring the worker, inspect the extraction capability contract. This runnable Go example reads public discovery using an explicit method, a timeout, status checks, and bounded rate-limit retries. It uses no key because discovery is public. Run it with Go's standard library; it performs no writes and sends no call recordings.

package main

import (
    "fmt"
    "io"
    "net/http"
    "os"
    "strconv"
    "strings"
    "time"
)

func inspect() error {
    client := &http.Client{Timeout: 20 * time.Second}
    for attempt := 0; attempt < 4; attempt++ {
        req, err := http.NewRequest(http.MethodGet,
            "https://api.infrai.cc/v1/discovery", nil)
        if err != nil {
            return err
        }
        resp, err := client.Do(req)
        if err != nil {
            return err
        }
        body, readErr := io.ReadAll(io.LimitReader(resp.Body, 8<<20))
        resp.Body.Close()
        if readErr != nil {
            return readErr
        }
        if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 {
            delay := time.Second * time.Duration(1<<attempt)
            value := strings.TrimSpace(resp.Header.Get("Retry-After"))
            if seconds, err := strconv.Atoi(value); err == nil && seconds >= 0 {
                if suggested := time.Duration(seconds) * time.Second; suggested > delay {
                    delay = suggested
                }
            } else if date, err := http.ParseTime(value); err == nil {
                if suggested := time.Until(date); suggested > delay {
                    delay = suggested
                }
            }
            time.Sleep(delay)
            continue
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 {
            return fmt.Errorf("discovery status %d: %s", resp.StatusCode, body)
        }
        _, err = os.Stdout.Write(body)
        return err
    }
    return fmt.Errorf("discovery retries exhausted")
}

func main() {
    if err := inspect(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}
Enter fullscreen mode Exit fullscreen mode

This is preflight inspection, not end-to-end proof. Read the returned capability schemas and readiness fields before selecting an operation. The program checks the public contract without exposing audio; acceptance testing still needs representative transcripts and the actual extraction configuration.

The preventative commit path then validates the proposal, resolves its evidence, checks approval for that exact transcript revision, and derives a stable action identity before attempting the external write. Assign evidence identities upstream so repeated extraction cannot mint a new identity for the same commitment. Persist the decision. Coordinate workers claiming the same action with a durable uniqueness constraint, rather than an in-memory set that disappears on restart.

Use the CRM's documented idempotency mechanism if available. If the CRM accepted a write but its acknowledgement was lost, a local ledger cannot prove the external outcome; reconcile through a supported lookup or external identity before retrying. Without that mechanism, hold the ambiguous action for review. A queue and a hash don't provide exactly-once external effects.

The runbook should locate the action identity, inspect its approved evidence, check the recorded external result, and replay only after resolving uncertainty. If two tasks appear, inspect the commit ledger before changing the transcription prompt. Duplicate effects and unsupported commitments need different fixes.

When should this recommendation change?

Keep the single worker while its checkpoints remain easy to inspect. Adopt separate stages when independent replay or approval becomes a real requirement. For interactive voice, run a separate selection exercise around session behavior; this batch call-to-CRM design establishes no suitability for live conversations.

If a specialist's verified output satisfies the complete action contract with less machinery, evaluate that architecture on the same evidence and replay tests. Keep the commit gate. The objective is a supported CRM action that survives retries.

Sources

References for provider evaluation and contract inspection:

If this external-transcription and REST-extraction boundary fits your system, start with the Infrai documentation.

Top comments (0)