Skip to content

Commit 3820fac

Browse files
author
dvonthenen
committed
Fix audio example for summary-ui
1 parent e4c8d84 commit 3820fac

File tree

7 files changed

+90
-8
lines changed

7 files changed

+90
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Using the Summary-UI API
2+
3+
This is a simple main-style sample application using Symbl's Summary UI API. This application will post an audio file to the platform and obtain the Summary results via a pre-canned UI when they become available.
4+
5+
## Getting started
6+
7+
Open `.env` file and add your APP_ID, APP_SECRET, SUMMARY_EMAIL. You can get APP_ID and APP_SECRET from [https://platform.symbl.ai](https://platform.symbl.ai)
8+
9+
Most of the heavy lifting is done in the `common` library which you can read about its plumbing [here](../../common/README.md).
10+
11+
## Async Conversation Processing
12+
13+
Obtaining intelligence on Summary using the Async API is pretty straight forward, the steps are:
14+
15+
1. Login
16+
2. Post the audio file and wait for the Symbl platform to process it
17+
3. Retrieve the URL for Summary UI
18+
19+
```
20+
async function main() {
21+
/*
22+
Login and get token
23+
*/
24+
var token = await common.Login();
25+
26+
/*
27+
Post the audio file to the Symbl platform
28+
*/
29+
var result = await posturl.PostAudioURL(token, process.env.URL);
30+
31+
/*
32+
Process Summary for the audio file
33+
*/
34+
var summary = await summaryui.SummaryAudioUI(token, process.env.URL, result.conversationId);
35+
var output = JSON.parse(summary);
36+
console.log(util.inspect(output, false, null, true));
37+
}
38+
39+
main();
40+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2022 Symbl.ai SDK contributors. All Rights Reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
require('dotenv').config()
5+
const util = require('util')
6+
7+
const common = require('../../common/common.js');
8+
const posturl = require('../../common/post-url.js');
9+
const summaryui = require('../../common/summary-ui.js');
10+
11+
async function main() {
12+
/*
13+
Login and get token
14+
*/
15+
var token = await common.Login();
16+
17+
/*
18+
Post the audio file to the Symbl platform
19+
*/
20+
var result = await posturl.PostAudioURL(token, process.env.URL);
21+
22+
/*
23+
Process Summary for the audio file
24+
*/
25+
var summary = await summaryui.SummaryAudioUI(token, process.env.URL, result.conversationId);
26+
var output = JSON.parse(summary);
27+
console.log(util.inspect(output, false, null, true));
28+
}
29+
30+
main();

examples/node/async-url/summary-ui-video/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ async function main() {
2424
var token = await common.Login();
2525
2626
/*
27-
Post the audio file to the Symbl platform
27+
Post the video file to the Symbl platform
2828
*/
2929
var result = await posturl.PostVideoURL(token, process.env.URL);
3030
3131
/*
32-
Process Summary for the audio file
32+
Process Summary for the video file
3333
*/
3434
var summary = await summaryui.SummaryVideoUI(token, process.env.URL, result.conversationId);
3535
var output = JSON.parse(summary);

examples/node/async-url/summary-ui-video/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ async function main() {
1515
var token = await common.Login();
1616

1717
/*
18-
Post the audio file to the Symbl platform
18+
Post the video file to the Symbl platform
1919
*/
2020
var result = await posturl.PostVideoURL(token, process.env.URL);
2121

2222
/*
23-
Process Summary for the audio file
23+
Process Summary for the video file
2424
*/
2525
var summary = await summaryui.SummaryVideoUI(token, process.env.URL, result.conversationId);
2626
var output = JSON.parse(summary);

examples/node/common/post-url.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ var common = require('./common.js');
66
const fetch = require('node-fetch');
77
var fs = require('fs');
88

9+
exports.PostAudioURL = async function(token, url) {
10+
return this.PostVideoURL(token, url)
11+
}
12+
913
exports.PostVideoURL = async function(token, url) {
10-
console.log(`video: ${url}\n`);
14+
console.log(`audio/video: ${url}\n`);
1115

1216
var status = await sendURL(token, url);
1317
var results = JSON.parse(status);
@@ -38,7 +42,11 @@ async function sendURL(token, url) {
3842
}
3943
var dataStr = JSON.stringify(data);
4044

41-
var uri = `https://api.symbl.ai/v1/process/video/url`;
45+
var uri = `https://api.symbl.ai/v1/process/audio/url`
46+
if (url.includes("mp4")) {
47+
uri = `https://api.symbl.ai/v1/process/video/url`;
48+
}
49+
4250
var response = await common.Query(uri, "POST", header, dataStr);
4351
var text = await response.text();
4452
// console.log("response: " + response);

examples/node/common/summary-ui.js

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ require('dotenv').config()
55
var common = require('./common.js');
66
const fetch = require('node-fetch');
77

8+
exports.SummaryAudioUI = async function(token, url, conversationId) {
9+
return this.SummaryVideoUI(token, url, conversationId)
10+
}
11+
812
exports.SummaryVideoUI = async function(token, url, conversationId) {
913
// console.log("conversationId: " + conversationId);
1014

run-example.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ case "${API_TYPE}" in
9999
;;
100100
"async-url")
101101
if [[ -z "${URL}" ]]; then
102-
echo "If you want to provide your own audio file, specify URL=\"HTTP URL\"."
102+
echo "If you want to provide your own audio/video file, specify URL=\"HTTP URL\"."
103103
echo "Otherwise, the default at the root of the repo will be provided."
104-
exit 1
104+
echo " "
105105
fi
106106
;;
107107
"management")

0 commit comments

Comments
 (0)