Skip to content

Commit

Permalink
Example on Sending Custom Param/Header
Browse files Browse the repository at this point in the history
  • Loading branch information
dvonthenen committed Dec 14, 2023
1 parent 1e72d2d commit ca64a41
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions examples/prerecorded/file/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
prettyjson "github.com/hokaccha/go-prettyjson"

prerecorded "github.com/deepgram/deepgram-go-sdk/pkg/api/prerecorded/v1"
cfginterfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces"
interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces"
client "github.com/deepgram/deepgram-go-sdk/pkg/client/prerecorded"
)
Expand All @@ -32,16 +33,26 @@ func main() {

// set the Transcription options
options := interfaces.PreRecordedTranscriptionOptions{
Punctuate: true,
Diarize: true,
Language: "en-US",
Utterances: true,
Punctuate: true,
Diarize: true,
Language: "en-US",
// Utterances: true, // Commenting this out to demonstrate how to send a custom parameter
}

// create a Deepgram client
c := client.NewWithDefaults()
dg := prerecorded.New(c)

// example on how to send a custom header
headers := make(map[string][]string, 0)
headers["MY-CUSTOM-HEADER"] = []string{"CUSTOM"}
ctx = cfginterfaces.WithCustomHeaders(ctx, headers)

// example on how to send a custom parameter
params := make(map[string][]string, 0)
params["utterances"] = []string{"true"}
ctx = cfginterfaces.WithCustomParameters(ctx, params)

// send/process file to Deepgram
res, err := dg.FromFile(ctx, filePath, options)
if err != nil {
Expand Down

0 comments on commit ca64a41

Please sign in to comment.