This package has been deprecated

Author message:

this package has been deprecated

@veritone/veritone-qs

1.0.23 • Public • Published

Veritone-qs Quick-Start guide.

This document assumes you have installed node. If you haven't please do so now. To test the the API; create a directory and in that directory run:

$ npm install @veritone/veritone-qs

Create a personal token

First we will need to create a file named console.js. Now edit that file and add the following lines into the blank console.js file:

var adminOptions = {
	baseUri: 'https://dev-core.veritone.com',
	token: 'cca96630-8680-49d6-8fdd-abfb21e9bef3'
}
var veritone = new Veritone(adminOptions);

var options = { tokenLabel: 'CoreAPI - Node Created Token' };
veritone.account.create(options, function(err, output) { console.log( output ); });

Now run the console to execute the token creation.

$ node console.js

In the output you will see something similar to:

{	
	tokenId: 'ibdyljow',
	tokenLabel: 'CoreAPI-CreatedToken',
	token: '27zk0jcv:65e3b8f025fb11e5adad8f203ff755b06eff5078114f43e981e16795c3d4675e',
	rights: [
		'job:create',
		'job:read',
		'job:delete',
		'task:update',
		'recording:create',
		'recording:read',
		'recording:update',
		'recording:delete',
		'analytics:sage'
	] 
}

The data we are interested in is the line reading token: '27zk0jcv:65e3b8f...', We are going to use it as our token for that of this sample. So copy it we will be pasting it in the next step.

Importing a file

Now edit the file we previously made named console.js and replace the lines:

var adminToken = '27zk0jcv:65e3b8f...
var veritone = new Veritone(adminToken);

var account = {firstName: ...
veritone.account.create(account, function(err, output) { console.log( output ); });

with:

var options = {
    token: '{TOKEN}'
};
var veritone = new Veritone(options);

var uri = {
	uri: uri: 'http://www.freeinfosociety.com/media/sounds/20.mp3',
	metadata: {
		size: 757186,
		filename: '20.mp3',
		container: 'CoreAPI Node Import'
	},
	startDateTime: Math.floor((new Date() / 1000)),
	endDateTime: Math.floor(new Date() /1000) + 92
};

veritone.media.import(uri, function(err, output) { console.log( output ); });

You should replace the text {TOKEN} with the corrected token we just generated. Make sure the line ends with a semi-colon not a comma. Save the file and run the console application:

$ node console.js

This will import a mp3 into the Veritone system. Depending on the file size you choose (and your internet connection) it may take a little time; however it should present a running notification. When it completes you should see an output something like:

{ 
	recordingId: '6735496',
	applicationId: 'cca96630-8680-49d6-8fdd-abfb21e9bef3',
	startDateTime: 1437429677,
	stopDateTime: 1437429855,
	metadata: 
	{
		size: 757186,
		filename: '2528.mp3',
		container: 'CoreAPI Node Import' 
	},
	createdDateTime: 1437429683,
	modifiedDateTime: 1437429688,
	status: 'uploaded',
	mediaAsset: 
	{
		assetId: '6735496.media',
		assetType: 'media',
		contentType: 'audio/mpeg' 
	},
	security: {
		global: false 
	} 
}

What we are interested in for the rest of this README is the 'recordingId:' value '6735496'

#Generating a transcript

Edit the console.js file again and replace the two lines:

var uri = {uri:...
veritone.media.import(uri,...

With:

var recordingId = {uid: '6735496'};
veritone.transcript.transcribe(recordingId, function(err, output) { console.log( output )});

You'll want to replace the UID value with whatever the 'recordingId' value your sample generated from the above output. Save the console.js file and run the new version.

$ node console.js

Transcriptions take a bit more time; however you should see a running notification as it processes. When complete you should see the transcript that was generated.

#Adding the transcript to your searchable index

Edit the console.js file; and replace the line:

veritone.transcript.transcribe(recordingId, function(err, output) { console.log( output )});

With:

veritone.search.add(recordingId, function(err, returnVal) { console.log( returnVal ) });

Save the new console.js file and run it.

$ node console.js

It will take a few moments to process the request; however you should see a running notice. The final output should b a repeat of the transcript that is processed into the index.

#Searching your index

Edit the console.js file again and replace the two lines:

var recordingId = {uid: '6362605'};
veritone.search.add(recordingId, function(err, output) { console.log( output ) });

With:

var search = {
	keywords: ['desk', 'vision']
};
veritone.search.query(search, function(err, output) { console.log( output ); });

Save the new version of console.js and run it.

$ node cosole.js

The output should return the breakdown on how many time the term was spoken in the transcribed file.

This concludes the quick start guide. Please feel free to edit and of the provided samples and look at the underlying code for further examples of how the low-level API operates.

Readme

Keywords

none

Package Sidebar

Install

npm i @veritone/veritone-qs

Weekly Downloads

1

Version

1.0.23

License

ISC

Last publish

Collaborators