npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

k2speech-speech-sdk

v1.0.6

Published

k2speech speech sdk java script version

Downloads

8

Readme

Introduction

This is the SDK for k2speech speech-to-text web API, to help user integrate the API into their javascript application, either in browser or in nodejs environment.

Features

  • [ ] Microphone audio source
  • [ ] File audio source
  • [ ] Websocket support
  • [ ] work in both browser and nodejs environment

Installation

# install from npm
npm i k2speech-speech-sdk

usage example

for nodejs:

# install third party libraries for this demo:
npm i fs
//import our sdk library: k2speech-speech-sdk
import pkg from 'k2speech-speech-sdk';
//import fs library for local file operation
import * as fs from "fs";
const {RecognizerConfig, Recognizer, FileAudioSource, Callback} = pkg;
//RecognizerConfig contains the configuration for Recognizer
//three argument are required:
//token(string): access token got from speech-to-text web portal, 
//ip(string): the deployed service ip or domain name
//port(string): the deployed service port
let config = new RecognizerConfig('testtoken', "3.82.117.197", "7000");
//use fs library to read test wave file
const file = fs.readFileSync('test.wav');
//create a file audio source object, as input of Recognizer
let source = new FileAudioSource(file, '');
//create the Recognizer object, using previous created 
//RecognizerConfig object and FileAudioSource object
let reco = new Recognizer(config, source)
//set open call back function which will be invoked 
//when the Recognizer connect to the service succesfully
reco.setOpenCallback(() =>{console.log("open callback");});
//set close call back function which will be invoked
//when the Recognizer connection is closed
reco.setCloseCallback(() =>{
    console.log("recognition result: " + reco.getRecognitionResult());
});
//set message call back function which will be invoked
//when the decode message is received, 
//it could happen in the period of decode process
reco.setMessageCallback((message) =>  {console.log("message:"+message)});
//use the Recognizer to start recognize
reco.recognize().then(() => {console.log("file sent!")});

for browser: file mode recognition:

<script src="dist/k2speech-sdk.browser.min.js"></script>

var files = document.getElementById('file').files;
const file = files[0];
//get token from speech-to-text web portal, set associated API ip and port
var config = new K2SpeechSDK.RecognizerConfig("testtoken", "3.82.117.197", "7000");
var source = new K2SpeechSDK.FileAudioSource(file, '');
var reco = new K2SpeechSDK.Recognizer(config, source)
reco.setOpenCallback(() =>{console.log("open callback");});
reco.setCloseCallback(() =>{console.log("recognized result: " + reco.getRecognitionResult())});
reco.setMessageCallback((message) =>  {console.log("message:"+message)});
reco.recognize().then(() => {console.log("file sent!")});

Microphone streaming recognition:

<script src="dist/k2speech-sdk.browser.min.js"></script>
//get token from speech-to-text web portal, set associated API ip and port
var config = new K2SpeechSDK.RecognizerConfig("testtoken", "3.82.117.197", "7000");
var source = new K2SpeechSDK.MicAudioSource();
var reco = new K2SpeechSDK.Recognizer(config, source)
reco.setOpenCallback(() =>{console.log("open callback");});
reco.setCloseCallback(() =>{console.log("recognized result: " + reco.getRecognitionResult())});
reco.setMessageCallback((message) =>  {console.log("message:"+message)});
reco.recognize().then(() => {console.log("Mic audio recognition started")});