Skip to content

Commit f89be6a

Browse files
authored
Merge pull request #22 from AssemblyAI/feat-webhooks
feat - add webhooks
2 parents 705f905 + a61d367 commit f89be6a

2 files changed

Lines changed: 32 additions & 13 deletions

File tree

cmd/transcribe.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ var transcribeCmd = &cobra.Command{
5959
policies, _ := cmd.Flags().GetString("redact_pii_policies")
6060
params.RedactPiiPolicies = strings.Split(policies, ",")
6161
}
62+
webhook := cmd.Flags().Lookup("webhook_url").Value.String()
63+
if webhook != "" {
64+
params.WebhookURL = webhook
65+
webhookHeaderName := cmd.Flags().Lookup("webhook_auth_header_name").Value.String()
66+
webhookHeaderValue := cmd.Flags().Lookup("webhook_auth_header_value").Value.String()
67+
if webhookHeaderName != "" {
68+
params.WebhookAuthHeaderName = webhookHeaderName
69+
}
70+
if webhookHeaderValue != "" {
71+
params.WebhookAuthHeaderValue = webhookHeaderValue
72+
}
73+
}
6274

6375
transcribe(params, flags)
6476
},
@@ -79,6 +91,9 @@ func init() {
7991
transcribeCmd.PersistentFlags().BoolP("sentiment_analysis", "x", false, "Detect the sentiment of each sentence of speech spoken in the file.")
8092
transcribeCmd.PersistentFlags().BoolP("speaker_labels", "l", true, "Automatically detect the number of speakers in your audio file, and each word in the transcription text can be associated with its speaker.")
8193
transcribeCmd.PersistentFlags().BoolP("topic_detection", "t", false, "Label the topics that are spoken in the file.")
94+
transcribeCmd.PersistentFlags().StringP("webhook_url", "w", "", "Receive a webhook once your transcript is complete.")
95+
transcribeCmd.PersistentFlags().StringP("webhook_auth_header_name", "b", "", "Containing the header's name which will be inserted into the webhook request")
96+
transcribeCmd.PersistentFlags().StringP("webhook_auth_header_value", "o", "", "The value of the header that will be inserted into the webhook request.")
8297
rootCmd.AddCommand(transcribeCmd)
8398
}
8499

@@ -132,6 +147,7 @@ func transcribe(params TranscribeParams, flags TranscribeFlags) {
132147

133148
TelemetryCaptureEvent("CLI transcription created", nil)
134149
body := bytes.NewReader(paramsJSON)
150+
135151
response := QueryApi("/transcript", "POST", body)
136152
var transcriptResponse TranscriptResponse
137153
if err := json.Unmarshal(response, &transcriptResponse); err != nil {

cmd/types.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,22 @@ type TranscribeFlags struct {
177177
}
178178

179179
type TranscribeParams struct {
180-
RedactPiiPolicies []string `json:"redact_pii_policies"`
181-
AudioURL string `json:"audio_url"`
182-
AutoChapters bool `json:"auto_chapters"`
183-
AutoHighlights bool `json:"auto_highlights"`
184-
ContentModeration bool `json:"content_safety"`
185-
DualChannel bool `json:"dual_channel"`
186-
EntityDetection bool `json:"entity_detection"`
187-
FormatText bool `json:"format_text"`
188-
Punctuate bool `json:"punctuate"`
189-
RedactPii bool `json:"redact_pii"`
190-
SentimentAnalysis bool `json:"sentiment_analysis"`
191-
SpeakerLabels bool `json:"speaker_labels"`
192-
TopicDetection bool `json:"iab_categories"`
180+
RedactPiiPolicies []string `json:"redact_pii_policies"`
181+
AudioURL string `json:"audio_url"`
182+
AutoChapters bool `json:"auto_chapters"`
183+
AutoHighlights bool `json:"auto_highlights"`
184+
ContentModeration bool `json:"content_safety"`
185+
DualChannel bool `json:"dual_channel"`
186+
EntityDetection bool `json:"entity_detection"`
187+
FormatText bool `json:"format_text"`
188+
Punctuate bool `json:"punctuate"`
189+
RedactPii bool `json:"redact_pii"`
190+
SentimentAnalysis bool `json:"sentiment_analysis"`
191+
SpeakerLabels bool `json:"speaker_labels"`
192+
TopicDetection bool `json:"iab_categories"`
193+
WebhookURL string `json:"webhook_url,omitempty"`
194+
WebhookAuthHeaderName string `json:"webhook_auth_header_name,omitempty"`
195+
WebhookAuthHeaderValue string `json:"webhook_auth_header_value,omitempty"`
193196
}
194197

195198
type RedactPiiPolicy string

0 commit comments

Comments
 (0)