Skip to content

Commit

Permalink
Merge pull request #157 from dvonthenen/impl-sits-prerecoerded
Browse files Browse the repository at this point in the history
Implement SITS for Prerecorded
  • Loading branch information
davidvonthenen authored Jan 19, 2024
2 parents 73a2707 + f05639f commit 78f8c6f
Show file tree
Hide file tree
Showing 12 changed files with 446 additions and 117 deletions.
Binary file not shown.
66 changes: 66 additions & 0 deletions examples/prerecorded/intent/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2023 Deepgram SDK contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

package main

import (
"context"
"encoding/json"
"fmt"
"os"

prettyjson "github.com/hokaccha/go-prettyjson"

prerecorded "github.com/deepgram/deepgram-go-sdk/pkg/api/prerecorded/v1"
interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces"
client "github.com/deepgram/deepgram-go-sdk/pkg/client/prerecorded"
)

const (
filePath string = "./CallCenterPhoneCall.mp3"
)

func main() {
// init library
client.Init(client.InitLib{
LogLevel: client.LogLevelStandard, // LogLevelStandard / LogLevelFull / LogLevelTrace
})

// Go context
ctx := context.Background()

// set the Transcription options
options := interfaces.PreRecordedTranscriptionOptions{
Model: "nova-2",
Punctuate: true,
Language: "en-US",
SmartFormat: true,
Intents: true,
}

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

// send/process file to Deepgram
res, err := dg.FromFile(ctx, filePath, options)
if err != nil {
fmt.Printf("FromStream failed. Err: %v\n", err)
os.Exit(1)
}

data, err := json.Marshal(res)
if err != nil {
fmt.Printf("json.Marshal failed. Err: %v\n", err)
os.Exit(1)
}

// make the JSON pretty
prettyJson, err := prettyjson.Format(data)
if err != nil {
fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err)
os.Exit(1)
}
fmt.Printf("\n\nResult:\n%s\n\n", prettyJson)
}
Binary file not shown.
66 changes: 66 additions & 0 deletions examples/prerecorded/sentiment/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2023 Deepgram SDK contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

package main

import (
"context"
"encoding/json"
"fmt"
"os"

prettyjson "github.com/hokaccha/go-prettyjson"

prerecorded "github.com/deepgram/deepgram-go-sdk/pkg/api/prerecorded/v1"
interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces"
client "github.com/deepgram/deepgram-go-sdk/pkg/client/prerecorded"
)

const (
filePath string = "./CallCenterPhoneCall.mp3"
)

func main() {
// init library
client.Init(client.InitLib{
LogLevel: client.LogLevelStandard, // LogLevelStandard / LogLevelFull / LogLevelTrace
})

// Go context
ctx := context.Background()

// set the Transcription options
options := interfaces.PreRecordedTranscriptionOptions{
Model: "nova-2",
Punctuate: true,
Language: "en-US",
SmartFormat: true,
Sentiment: true,
}

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

// send/process file to Deepgram
res, err := dg.FromFile(ctx, filePath, options)
if err != nil {
fmt.Printf("FromStream failed. Err: %v\n", err)
os.Exit(1)
}

data, err := json.Marshal(res)
if err != nil {
fmt.Printf("json.Marshal failed. Err: %v\n", err)
os.Exit(1)
}

// make the JSON pretty
prettyJson, err := prettyjson.Format(data)
if err != nil {
fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err)
os.Exit(1)
}
fmt.Printf("\n\nResult:\n%s\n\n", prettyJson)
}
Binary file not shown.
66 changes: 66 additions & 0 deletions examples/prerecorded/summary/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2023 Deepgram SDK contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

package main

import (
"context"
"encoding/json"
"fmt"
"os"

prettyjson "github.com/hokaccha/go-prettyjson"

prerecorded "github.com/deepgram/deepgram-go-sdk/pkg/api/prerecorded/v1"
interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces"
client "github.com/deepgram/deepgram-go-sdk/pkg/client/prerecorded"
)

const (
filePath string = "./CallCenterPhoneCall.mp3"
)

func main() {
// init library
client.Init(client.InitLib{
LogLevel: client.LogLevelStandard, // LogLevelStandard / LogLevelFull / LogLevelTrace
})

// Go context
ctx := context.Background()

// set the Transcription options
options := interfaces.PreRecordedTranscriptionOptions{
Model: "nova-2",
Punctuate: true,
Language: "en-US",
SmartFormat: true,
Summarize: "v2",
}

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

// send/process file to Deepgram
res, err := dg.FromFile(ctx, filePath, options)
if err != nil {
fmt.Printf("FromStream failed. Err: %v\n", err)
os.Exit(1)
}

data, err := json.Marshal(res)
if err != nil {
fmt.Printf("json.Marshal failed. Err: %v\n", err)
os.Exit(1)
}

// make the JSON pretty
prettyJson, err := prettyjson.Format(data)
if err != nil {
fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err)
os.Exit(1)
}
fmt.Printf("\n\nResult:\n%s\n\n", prettyJson)
}
Binary file not shown.
66 changes: 66 additions & 0 deletions examples/prerecorded/topic/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2023 Deepgram SDK contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

package main

import (
"context"
"encoding/json"
"fmt"
"os"

prettyjson "github.com/hokaccha/go-prettyjson"

prerecorded "github.com/deepgram/deepgram-go-sdk/pkg/api/prerecorded/v1"
interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces"
client "github.com/deepgram/deepgram-go-sdk/pkg/client/prerecorded"
)

const (
filePath string = "./CallCenterPhoneCall.mp3"
)

func main() {
// init library
client.Init(client.InitLib{
LogLevel: client.LogLevelStandard, // LogLevelStandard / LogLevelFull / LogLevelTrace
})

// Go context
ctx := context.Background()

// set the Transcription options
options := interfaces.PreRecordedTranscriptionOptions{
Model: "nova-2",
Punctuate: true,
Language: "en-US",
SmartFormat: true,
Topics: true,
}

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

// send/process file to Deepgram
res, err := dg.FromFile(ctx, filePath, options)
if err != nil {
fmt.Printf("FromStream failed. Err: %v\n", err)
os.Exit(1)
}

data, err := json.Marshal(res)
if err != nil {
fmt.Printf("json.Marshal failed. Err: %v\n", err)
os.Exit(1)
}

// make the JSON pretty
prettyJson, err := prettyjson.Format(data)
if err != nil {
fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err)
os.Exit(1)
}
fmt.Printf("\n\nResult:\n%s\n\n", prettyJson)
}
3 changes: 0 additions & 3 deletions pkg/api/prerecorded/v1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,4 @@ import (
var (
// ErrInvalidInput required input was not found
ErrInvalidInput = errors.New("required input was not found")

// ErrInvalidURIExtension couldn't find a period to indicate a file extension
ErrInvalidURIExtension = errors.New("couldn't find a period to indicate a file extension")
)
Loading

0 comments on commit 78f8c6f

Please sign in to comment.