-
Notifications
You must be signed in to change notification settings - Fork 36
Analyse text
You can use the Recast.AI API to analyse your text or your audio file, and extract useful informations from it.
Start by instantiating a Client instance, as showed on this page.
var recastai = require('recastai')
var client = new recastai.Client(YOUR_TEXT, YOUR_LANGUAGE)
import { Client } from 'recastai'
const client = new Client(YOUR_TEXT, YOUR_LANGUAGE)
Use the textRequest method of the client, and after a call to our API, we will return to you a Response object containing the enriched entities extracted from your text, the intents detected and some more useful informations (a comprehensive list can be found here).
Please note that the length of the text is limited to 256 chars by call.
client.textRequest(YOUR_TEXT)
.then(function(res) {
// get the intent detected
var intent = res.intent()
// get all the location entities extracted from your text
var locations = res.all('location')
// Do your code
}).catch(function(err) {
// Handle error
})
Use the fileRequest method of the client, and after a call to our API, we will return to you a Response object containing the enriched entities extracted from your audio file, the intents detected and some more useful informations (a comprehensive list can be found here).
Please note that the length of the audio is limited to 10 seconds by call.
client.fileRequest(YOUR_FILE_REQUEST)
.then(function(res) {
// get the intent detected
var intent = res.intent()
// get all the location entities extracted from your text
var locations = res.all('location')
// Do your code
}).catch(function(err) {
// Handle error
})
For more information, do not hesitate to dive deeper in the documentation, you'll find the full specs of each classes with attributes and methods detailed. You can also look at the code as it is commented ;-)