Giter Site home page Giter Site logo

revdotcom / revai-node-sdk Goto Github PK

View Code? Open in Web Editor NEW
21.0 41.0 12.0 1.79 MB

Node.js SDK for the Rev AI API

License: MIT License

TypeScript 76.96% JavaScript 22.98% Dockerfile 0.06%
speech-recognition speech-to-text realtime sdk rev captions nodejs revai

revai-node-sdk's People

Contributors

aaron-wilson-rev avatar amikofalvy avatar beaudrychase avatar bwagner avatar celineqiu avatar chanc3 avatar dependabot[bot] avatar eugenep-rev avatar github-actions[bot] avatar hbkse avatar jadesym avatar jennywong2129 avatar k-weng avatar kbridbur avatar kirillatrev avatar kostasrev avatar kshiflett88 avatar lrgottlieb avatar menioa avatar pjhuck avatar seanlam8 avatar timitijani avatar ymardini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

revai-node-sdk's Issues

Add changelog or release notes

Hello,

We're using this library for our RevAI integration and seeing that some updates are being made but there is no public documentation to understand what breaking changes or new features are being added. Is it possible to add the support for this?

Thansk

File size limited to 10mb

This project uses axios, which limits the body size to 10mb by default (via maxBodyLength). See https://axios-http.com/docs/req_config.

This limit should probably be increased to 2gb to match the API, or at least be configurable. Currently the submitJobLocalFile will throw an error if files larger than 10mb

Support EU based rev.ai accounts

Issue

EU based accounts require a different base URL (source):
image

Yet, the SDK hardcodes the US based URL:

this.apiHandler = new ApiRequestHandler(`https://api.rev.ai/speechtotext/${version}/`, accessToken);

Workaround

It's possible to overwrite the apiHandler field of the client (by plugging into the internal API):

import { RevAiApiClient } from 'revai-node-sdk';
import { ApiRequestHandler } from 'revai-node-sdk/src/api-request-handler';

...

const client = new RevAiApiClient(accessToken);
client.apiHandler = new ApiRequestHandler('https://ec1.api.rev.ai/speechtotext/v1/', accessToken);

Streaming client: crash after unsafeEnd

Calling RevAiStreamingClient's client.unsafeEnd() often leads to a crash:

Error [ERR_STREAM_PUSH_AFTER_EOF]: stream.push() after EOF
    at readableAddChunk (_stream_readable.js:257:32)
    at PassThrough.Readable.push (_stream_readable.js:224:10)
    at PassThrough.Transform.push (_stream_transform.js:151:32)
    at PassThrough.afterTransform (_stream_transform.js:92:10)
    at PassThrough._transform (_stream_passthrough.js:42:3)
    at PassThrough.Transform._read (_stream_transform.js:190:10)
    at PassThrough.Transform._write (_stream_transform.js:178:12)
    at doWrite (_stream_writable.js:415:12)
    at writeOrBuffer (_stream_writable.js:399:5)
    at PassThrough.Writable.write (_stream_writable.js:299:11)
Emitted 'error' event at:
    at errorOrDestroy (internal/streams/destroy.js:107:12)
    at readableAddChunk (_stream_readable.js:257:9)
    at PassThrough.Readable.push (_stream_readable.js:224:10)
    [... lines matching original stack trace ...]
    at writeOrBuffer (_stream_writable.js:399:5)

What's happening here is that unsafeEnd is calling closeStreams, which executes this.responses.push(null). Once null has been pushed onto a stream, you cannot push to it again. Then, as the connection gets a response from rev.ai, we write to this.response again:

this.responses.write(response as StreamingHypothesis);

Reproduction of this crash: https://codesandbox.io/s/revai-node-sdk-crash-hpy8u?file=/src/index.js (assign a rev.ai API token to the "token" variable). This is the streaming example from the document + a call to unsafeEnd before we've sent/received all of the results.

Something like this should fix it:

diff --git a/src/streaming-client.ts b/src/streaming-client.ts
index 8374e49..f56715e 100644
--- a/src/streaming-client.ts
+++ b/src/streaming-client.ts
@@ -34,6 +34,7 @@ export class RevAiStreamingClient extends EventEmitter {
     private config: AudioConfig;
     private requests: PassThrough;
     private responses: PassThrough;
+    private streamsClosed: boolean;
 
     /**
      * @param accessToken Access token associated with the user's account
@@ -130,6 +131,9 @@ export class RevAiStreamingClient extends EventEmitter {
                 this.closeStreams();
             });
             connection.on('message', (message: any) => {
+                if (this.streamsClosed) {
+                    return;
+                }
                 if (message.type === 'utf8') {
                     let response = JSON.parse(message.utf8Data);
                     if ((response as StreamingResponse).type === 'connected') {
@@ -159,5 +163,6 @@ export class RevAiStreamingClient extends EventEmitter {
     private closeStreams(): void {
         this.requests.end();
         this.responses.push(null);
+        this.streamsClosed = true;
     }
-}
\ No newline at end of file
+}

use in chrome extension

Is it possible to use the streaming api in a chrome extension ?
When I tried, I first had issue with 'fs' module being unavailable, but it doesn't seem necessary for my use case.
After deletion of 'fs' references,
the code block on this call:

        client = new revai.RevAiStreamingClient(token, audioConfig)

live stream : 2.6.2 upg to 3x partials are now super slow to come in over sockets

We need to upgrade to 3.0 to get away from the issue around dropped sockets connections with mistaken closure strings in the feed, however when we upgrade to 3x the partials inbound are so slow that it is not possible to use for our captions any-longer.
Are we possibly missing a new configuration flag that would return partials with the expediency of 2.62?
we are using ffmpeg to add a wav audio into a pipe.
our session config is:

const getSessionConfig = (streamID, vocab) => new revai.SessionConfig(
   metadata=streamID,  /* (optional) metadata */
   customVocabularyID=vocab,  /* (optional) custom_vocabulary_id */
   filterProfanity=true,    /* (optional) filter_profanity */
   removeDisfluencies=true, /* (optional) remove_disfluencies */
);

what was millisecond return latency is now over 10 to 20 seconds to get partials using the newest version

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.