-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
114 changed files
with
3,890 additions
and
621 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -20,3 +20,4 @@ code-samples/**/obj/* | |
*.sln | ||
.idea/ | ||
*.iml | ||
*.mp3 |
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,34 @@ | ||
package AIServer; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.eclipse.jetty.server.Request; | ||
import org.eclipse.jetty.server.Server; | ||
import org.eclipse.jetty.server.handler.AbstractHandler; | ||
|
||
public class WebhookServer extends AbstractHandler | ||
{ | ||
public static void main( String[] args ) throws Exception | ||
{ | ||
Server server = new Server(3000); | ||
server.setHandler(new WebhookServer()); | ||
server.start(); | ||
server.join(); | ||
} | ||
|
||
@Override | ||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException | ||
{ | ||
response.setStatus(HttpServletResponse.SC_OK); | ||
if (request.getMethod() == "POST" && request.getPathInfo().equals("/webhook")) | ||
{ | ||
String body = request.getReader().lines().collect( java.util.stream.Collectors.joining(System.lineSeparator()) ); | ||
System.out.println(body); | ||
} | ||
baseRequest.setHandled(true); | ||
} | ||
} |
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,5 @@ | ||
# Instantiate the SDK and get the platform instance | ||
rcsdk = SDK("PRODUCTION-APP-CLIENTID", "PRODUCTION-APP-CLIENTSECRET", "https://platform.ringcentral.com") | ||
platform = rcsdk.platform() | ||
|
||
login() |
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,4 @@ | ||
# Instantiate the SDK and get the platform instance | ||
$platform = RingCentral.new( "PRODUCTION-APP-CLIENTID", "PRODUCTION-APP-CLIENTSECRET", "https://platform.ringcentral.com" ) | ||
|
||
login() |
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,13 @@ | ||
const fs = require ('fs') | ||
const RC = require('@ringcentral/sdk').SDK | ||
|
||
// Instantiate the SDK and get the platform instance | ||
var rcsdk = new RC({ | ||
server: 'https://platform.devtest.ringcentral.com', | ||
clientId: 'PRODUCTION-APP-CLIENTID', | ||
clientSecret: 'PRODUCTION-APP-CLIENTSECRET' | ||
}); | ||
var platform = rcsdk.platform(); | ||
|
||
/* Authenticate a user using a personal JWT token */ | ||
platform.login({ jwt: 'PRODUCTION-JWT' }) |
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,10 @@ | ||
<?php | ||
require('vendor/autoload.php'); | ||
|
||
// Instantiate the SDK and get the platform instance | ||
$rcsdk = new RingCentral\SDK\SDK( 'PRODUCTION-APP-CLIENTID', 'PRODUCTION-APP-CLIENTSECRET', 'https://platform.ringcentral.com' ); | ||
$platform = $rcsdk->platform(); | ||
|
||
/* Authenticate a user using a personal JWT token */ | ||
$platform->login(["jwt" => 'PRODUCTION-JWT']); | ||
?> |
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,48 @@ | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using System.Collections.Generic; | ||
using RingCentral; | ||
using Newtonsoft.Json; | ||
|
||
namespace AnalyzeInteraction { | ||
class Program { | ||
static RestClient restClient; | ||
static async Task Main(string[] args){ | ||
try | ||
{ | ||
// Instantiate the SDK | ||
restClient = new RestClient("PRODUCTION-APP-CLIENT-ID", "PRODUCTION-APP-CLIENT-SECRET", "https://platform.ringcentral.com"); | ||
|
||
// Authenticate a user using a personal JWT token | ||
await restClient.Authorize("PRODUCTION-JWT"); | ||
|
||
await check_task_status("jobId"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine("Unable to authenticate to platform. Check credentials. " + ex.Message); | ||
} | ||
} | ||
/* | ||
* Check async task status | ||
*/ | ||
static private async Task check_task_status(String jobId) | ||
{ | ||
try | ||
{ | ||
var resp = await restClient.Ai().Status().V1().Jobs(jobId).Get(); | ||
Console.WriteLine(JsonConvert.SerializeObject(resp)); | ||
if (resp.completionTime == null) | ||
{ | ||
await Task.Delay(50000); | ||
await check_status(jobId); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine("Unable to read async task status. " + ex.Message); | ||
} | ||
} | ||
} | ||
} |
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,48 @@ | ||
package AnalyzeInteraction; | ||
|
||
import java.io.IOException; | ||
import com.google.common.reflect.TypeToken; | ||
import com.google.gson.Gson; | ||
|
||
import com.ringcentral.*; | ||
import com.ringcentral.definitions.*; | ||
|
||
public class AnalyzeInteraction { | ||
static RestClient restClient; | ||
|
||
public static void main(String[] args) { | ||
var obj = new AnalyzeInteraction(); | ||
try { | ||
// Instantiate the SDK | ||
restClient = new RestClient("PRODUCTION-APP-CLIENT-ID", "PRODUCTION-APP-CLIENT-SECRET", "https://platform.ringcentral.com"); | ||
|
||
// Authenticate a user using a personal JWT token | ||
restClient.authorize("PRODUCTION-JWT"); | ||
|
||
obj.check_task_status("jobId"); | ||
|
||
} catch (RestException e) { | ||
System.out.println(e.getMessage()); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
/* | ||
* Check task status | ||
*/ | ||
private void check_task_status(String jobId) | ||
{ | ||
try { | ||
var resp = restClient.ai().status().v1().jobs(jobId).get(); | ||
@SuppressWarnings("serial") | ||
String jsonStr = new Gson().toJson(resp, new TypeToken<Object>(){}.getType()); | ||
System.out.println(jsonStr); | ||
if (resp.completionTime == null) { | ||
Thread.sleep(5000l); | ||
check_task_status(jobId); | ||
} | ||
} catch (Exception ex) { | ||
System.out.println("Unable to read async task status. " + ex.getMessage()); | ||
} | ||
} | ||
} |
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,31 @@ | ||
var platform = require('./../quick-start.js').platform; | ||
check_task_status("5b161b98-62c9-11ee-877c-0050568ca439") | ||
|
||
|
||
|
||
|
||
|
||
|
||
// Next line must be at the 10th line! | ||
platform.on(platform.events.loginSuccess, () => { | ||
check_task_status("") | ||
}) | ||
|
||
platform.on(platform.events.loginError, function(e){ | ||
console.log("Unable to authenticate to platform. Check credentials.", e.message) | ||
process.exit(1) | ||
}); | ||
|
||
/* | ||
* Check speech to text job status | ||
*/ | ||
async function check_task_status(jobId) { | ||
try{ | ||
var endpoint = `/ai/status/v1/jobs/${jobId}` | ||
var resp = await platform.get(endpoint) | ||
var jsonObj = await resp.json() | ||
console.log(JSON.stringify(jsonObj)) | ||
}catch (e){ | ||
console.log("Unable to get speech to text job status.", e.message) | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
check_task_status("1cb4eb26-0159-11ee-b349-0050568c5fe3"); | ||
|
||
/* | ||
* Check speech to text job status | ||
*/ | ||
function check_task_status($jobId) | ||
{ | ||
global $platform; | ||
try{ | ||
$endpoint = "/ai/status/v1/jobs/" . $jobId; | ||
$resp = $platform->get($endpoint); | ||
print_r (json_encode($resp->json(), JSON_PRETTY_PRINT)); | ||
}catch (\RingCentral\SDK\Http\ApiException $e) { | ||
print_r ('Unable to get speech to text job status. ' . $e->getMessage() . PHP_EOL); | ||
} | ||
} | ||
?> |
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,24 @@ | ||
from ringcentral import SDK | ||
import json | ||
|
||
# | ||
# Check speech to text job status | ||
# | ||
def check_task_status(jobId): | ||
try: | ||
endpoint = f'/ai/status/v1/jobs/{jobId}' | ||
resp = platform.get(endpoint) | ||
jsonObj = resp.json_dict() | ||
print(json.dumps(jsonObj, indent=2, sort_keys=True)) | ||
except Exception as e: | ||
print ("Unable to get speech to text job status. " + str(e)) | ||
|
||
|
||
|
||
# Authenticate a user using a personal JWT token | ||
def login(): | ||
try: | ||
platform.login( jwt= "PRODUCTION-JWT" ) | ||
check_task_status("jobId") | ||
except Exception as e: | ||
print ("Unable to authenticate to platform. Check credentials. " + str(e)) |
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,26 @@ | ||
require 'ringcentral' | ||
|
||
# | ||
# Check speech to text job status | ||
# | ||
def check_task_status(jobId) | ||
begin | ||
endpoint = "/ai/status/v1/jobs/" + jobId | ||
resp = $platform.get(endpoint) | ||
jsonObj = resp.body | ||
puts (jsonObj) | ||
rescue StandardError => e | ||
puts ("Unable to get speech to text job status. " + e.to_s) | ||
end | ||
end | ||
|
||
|
||
# Authenticate a user using a personal JWT token | ||
def login() | ||
begin | ||
$platform.authorize( jwt: "PRODUCTION-JWT" ) | ||
check_task_status("jobId") | ||
rescue StandardError => e | ||
puts ("Unable to authenticate to platform. Check credentials. " + e.to_s) | ||
end | ||
end |
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 @@ | ||
[{"start":3.72,"end":8.68,"text":"Good evening, thank you for calling electronics or this is Rachel, how may I assist you?","speakerId":"1"},{"start":8.68,"end":9.84,"text":"Hi, Rachel.","speakerId":"1"},{"start":8.76,"end":13.8,"text":"Hi, Rachel, I would like to know how to use this car Bluetooth hese I recently purchased from your store.","speakerId":"0"},{"start":9.84,"end":11.2,"text":"I would like to know how to use this car.","speakerId":"1"},{"start":11.2,"end":13.84,"text":"Bluetooth hee I recently purchased from your store.","speakerId":"1"},{"start":13.8,"end":21.2,"text":"Sure, ma'am, I can help you out with that, but before anything else, may I have your name so that I can address you properly.","speakerId":"0"},{"start":13.84,"end":20.64,"text":"Sure, ma'am, I can help you with that, but before anything else, I have your name so that I can address you.","speakerId":"1"},{"start":20.64,"end":21.12,"text":"Properly.","speakerId":"1"},{"start":21.12,"end":23.04,"text":"Yes, this is Meredith Blake.","speakerId":"1"},{"start":21.2,"end":23.04,"text":"Yes, this is me flake.","speakerId":"0"},{"start":23.04,"end":26.4,"text":"Okay, thank you for that, Mrs Plague.","speakerId":"0"},{"start":23.04,"end":29.36,"text":"Okay, thank you for that, Mrs Plake, what exactly do you want done with your headset?","speakerId":"1"},{"start":26.4,"end":29.36,"text":"What exactly do you want done with your headset?","speakerId":"0"},{"start":29.36,"end":31.44,"text":"I want to know how to use it.","speakerId":"0"},{"start":29.36,"end":31.44,"text":"I want to know how to use it.","speakerId":"1"},{"start":31.44,"end":38.76,"text":"Okay, ma'am, I may get your headsets, modal name and number as well as that of your phone.","speakerId":"0"},{"start":31.44,"end":38.8,"text":"Okay, ma'am, I may get your headsets modal name and number as well as that of for phone.","speakerId":"1"},{"start":38.76,"end":44.68,"text":"I bought a Plantronics Mark 2m165 and I use an iphone for us.","speakerId":"0"},{"start":38.8,"end":46.24,"text":"Uh, I bought a Plantronics Mark 2m165 and I use an iphone for S. Okay, ma'am.","speakerId":"1"},{"start":44.68,"end":46.28,"text":"Okay, ma'am?","speakerId":"0"},{"start":46.24,"end":50.96,"text":"So have you tried already pairing it with your headset with your phone?","speakerId":"1"},{"start":46.28,"end":51,"text":"So have you tried fairly pairing it with your headset with your phone?","speakerId":"0"},{"start":50.96,"end":53.76,"text":"Yes, I have, okay.","speakerId":"1"},{"start":51,"end":53.8,"text":"Yes, I have, okay.","speakerId":"0"},{"start":53.76,"end":61.12,"text":"First, I need you to unpair your device with your phone unpaid.","speakerId":"1"},{"start":53.8,"end":61.2,"text":"First, I need you to unpair, um, your device with your phone and king.","speakerId":"0"},{"start":61.12,"end":73.84,"text":"Yes, ma'am, OK, done now, please switch off your phone, then turn it On again after around 5 s, switch it off and on.","speakerId":"1"},{"start":61.2,"end":64.96,"text":"Yes, ma'am, okay, done","speakerId":"0"},{"start":66.28,"end":73.88,"text":"Now please switch off your phone, then turn it on again after around 5 s, switch it off and on.","speakerId":"0"},{"start":73.84,"end":77.28,"text":"Yes, please done now what?","speakerId":"1"},{"start":73.88,"end":77.32,"text":"Yes, please done now what?","speakerId":"0"},{"start":77.28,"end":82.28,"text":"Okay, please it with your phone, okay?","speakerId":"1"},{"start":77.32,"end":82.28,"text":"OK, please pair it with your phone, okay?","speakerId":"0"},{"start":82.28,"end":86.88,"text":"Now, what, ma'am, is their headset working?","speakerId":"1"},{"start":82.28,"end":86.84,"text":"Paired now what, ma'am, is your headset working?","speakerId":"0"},{"start":86.84,"end":90.04,"text":"Now that is just it, I want to know how it works.","speakerId":"0"},{"start":86.88,"end":90.08,"text":"Now that is just it I want to know how it works.","speakerId":"1"},{"start":90.04,"end":94.36,"text":"I already told you that I have paired the device with my phone, but I am not sure if you get what I mean.","speakerId":"0"},{"start":90.08,"end":93.36,"text":"I already told you that I have paired the device with my phone, but I am not Sure.","speakerId":"1"},{"start":93.36,"end":98.16,"text":"If you get what I mean, well, yes, ma'am, I understand where you are coming from.","speakerId":"1"},{"start":94.36,"end":98.2,"text":"I well, yes, ma'am, I understand where you're coming from.","speakerId":"0"},{"start":98.16,"end":100.88,"text":"That is why I am trying to help you.","speakerId":"1"},{"start":98.2,"end":100.84,"text":"That's why I am trying to help you.","speakerId":"0"},{"start":100.84,"end":104.04,"text":"Okay, well, we have already done that.","speakerId":"0"},{"start":100.88,"end":104,"text":"Okay, well, we have already done that.","speakerId":"1"},{"start":104,"end":107.2,"text":"I only ask a simple question, why can not you seem to get that?","speakerId":"1"},{"start":104.04,"end":111.72,"text":"I only ask a simple question, why can't you seem to Get that, yes, ma'am, I understand where you are coming from.","speakerId":"0"},{"start":107.2,"end":111.76,"text":"Yes, ma'am, I understand where you are coming from.","speakerId":"1"},{"start":111.72,"end":114.28,"text":"That is why I am trying to help you.","speakerId":"0"},{"start":111.76,"end":114.8,"text":"That is Why, I am trying to help, you know what?","speakerId":"1"},{"start":114.28,"end":116.48,"text":"No, no 1 I don't think you you do.","speakerId":"0"},{"start":114.8,"end":116.4,"text":"No, I I do not think you do.","speakerId":"1"},{"start":116.4,"end":120.32,"text":"We have been at this for over 30 min going around in circles.","speakerId":"1"},{"start":116.48,"end":120.32,"text":"We have been at this for over 30 min going around in circles.","speakerId":"0"},{"start":120.32,"end":122,"text":"I would like to speak to your supervisor.","speakerId":"1"},{"start":120.32,"end":122,"text":"I would like to speak to your supervisor.","speakerId":"0"},{"start":122,"end":123.84,"text":"I obviously will not get any help from you","speakerId":"1"},{"start":122,"end":123.76,"text":"Obviously will not get any help from you","speakerId":"0"}] |
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,13 @@ | ||
[ | ||
"Hey What’s your plan tonight?", | ||
"No plans, I think I will relax at home. Work was busy today.", | ||
"I just got home too. Busy day! Do you want to go to the cinema? There’s a great movie playing downtown.", | ||
"Hmmm. What time? What movie?", | ||
"Oh. Marvel. . . Actually I hate Marvel. I never spend money on Marvel movies. They are too boring.", | ||
"If you want, I will buy you a ticket. My treat.", | ||
"No thanks, I really don’t like Marvel.", | ||
"Okay. I will also buy you popcorn and a drink.", | ||
"I’m really not interested in Iron Man.", | ||
"Okay. Maybe I’ll take you shopping after the movie?", | ||
"Amazing! You are the best boyfriend ever. Pick me up at 7:30." | ||
] |
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,70 @@ | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using System.Collections.Generic; | ||
using RingCentral; | ||
using Newtonsoft.Json; | ||
|
||
namespace SpeakserIdentificationEnrollment { | ||
class Program { | ||
static RestClient restClient; | ||
static async Task Main(string[] args){ | ||
try | ||
{ | ||
// Instantiate the SDK | ||
restClient = new RestClient("PRODUCTION-APP-CLIENT-ID", "PRODUCTION-APP-CLIENT-SECRET", "https://platform.ringcentral.com"); | ||
|
||
// Authenticate a user using a personal JWT token | ||
await restClient.Authorize("PRODUCTION-JWT"); | ||
|
||
await read_enrollments(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine("Unable to authenticate to platform. Check credentials. " + ex.Message); | ||
} | ||
} | ||
/* | ||
* Read speakers identification | ||
*/ | ||
static private async Task read_enrollments() | ||
{ | ||
try | ||
{ | ||
var queryParams = new CaiEnrollmentsListParameters() | ||
{ | ||
partial = true, | ||
perPage = 100, | ||
page = 1 | ||
}; | ||
|
||
var resp = await restClient.Ai().Audio().V1().Enrollments().List(queryParams); | ||
Console.WriteLine(JsonConvert.SerializeObject(resp)); | ||
foreach (var record in resp.records) | ||
{ | ||
if (record.enrollmentId == "62288329016") | ||
{ | ||
await delete_enrollment(record.enrollmentId); | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine("Unable to read speakers identification. " + ex.Message); | ||
} | ||
} | ||
// Delet a speakers identification | ||
static private async Task delete_enrollment(String enrollmentId) | ||
{ | ||
try | ||
{ | ||
var resp = await restClient.Ai().Audio().V1().Enrollments(enrollmentId).Delete(); | ||
Console.WriteLine("Deleted"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine("Unable to delete a speaker identification. " + ex.Message); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.