Smart punctuation
The Smart Punctuation API takes a block of text and augments it with proper punctuation using artificial intelligence, and is specifically optimized in the processing of speech recognition output. The API will augment text with the following punctuation:
- Periods, full-stop:
.
- Commas:
,
- Quotes:
'
"
- Question marks:
?
- Exclamation marks:
!
- Apostrophes:
'
, contractions and possessive forms - Proper capitalization, sentence-cap and acronyms
Augmenting text with proper punctuation
Request parameters
Parameter | Type | Description |
---|---|---|
texts |
List | List of unformatted text blobs. |
Example code
After you have setup a simple web server to process the response, copy and paste the code from below in a file. In the process, make sure to edit the variables found in ALL CAPS to ensure your code runs properly.
const RC = require('@ringcentral/sdk').SDK;
require('dotenv').config();
// replace with your ngrok address below
const WEBHOOK_URL = "YOUR NGROK HTTPS URL" + "/webhook";
// Initialize the RingCentral SDK and Platform
const rcsdk = new RC({
'server': process.env.RC_SERVER_URL,
'clientId': process.env.RC_CLIENT_ID,
'clientSecret': process.env.RC_CLIENT_SECRET
});
const platform = rcsdk.platform();
// Authenticate with RingCentral Developer Platdorm using Developer's JWT Credential
platform.login({
'jwt': process.env.RC_JWT
});
// Call the Speech to Text API right after login asynchronously
platform.on(platform.events.loginSuccess, () => {
punctuateText();
});
async function punctuateText() {
try {
let resp = await platform.post("/ai/text/v1/async/punctuate?webhook=" + WEBHOOK_URL, {
texts: [
"so its more fluid than it is and you know its not the best kind of feedback right"
]
});
console.log("Job is " + resp.statusText + " with HTTP status code " + resp.status);
}
catch (e) {
console.log("An error occurred: " + e.message);
}
}
Run your sample code.
$ node index.js
import os,sys
import logging
import requests
from ringcentral import SDK
from dotenv import load_dotenv
WEBHOOK_URL = "<INSERT WEBHOOK URL>"
# Load Enviroment variables
load_dotenv()
# Invoke Smart Punctuate API
def smartPunctuate():
# Endpoint to invoke Smart Punctuate API
endpoint = os.getenv('RC_SERVER_URL')+"/ai/text/v1/async/punctuate"
# Webhook as Query string
querystring = { "webhook": WEBHOOK_URL }
# Payload
payload = {
"texts": [
"so its more fluid than it is and you know its not the best kind of feedback right"
]
}
try:
# Instantiate Ringcentral SDK
rcsdk = SDK( os.getenv('RC_CLIENT_ID'),os.getenv('RC_CLIENT_SECRET'),os.getenv('RC_SERVER_URL'))
platform = rcsdk.platform()
# Login Using JWT
platform.login( jwt=os.getenv('RC_JWT') );
# Make HTTP POST call to the smart punctuate endpoint with the query string and payload
response = platform.post(endpoint, payload, querystring);
print(response.json());
except Exception as e:
print(e)
try:
smartPunctuate()
except Exception as e:
print(e)
Run your sample code.
$ python3 app.py
Example response
{
"status": "Success",
"response": {
"texts":
[
"So it's more fluid than it is, and you know it's not the best kind of feedback, right?"
]
}
}