-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from dvonthenen/impl-sits-prerecoerded
Implement SITS for Prerecorded
- Loading branch information
Showing
12 changed files
with
446 additions
and
117 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.