JSPM

@speechmatics/auth

0.1.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 4367
    • Score
      100M100P100Q120524F
    • License MIT

    Library for fetching temporary keys for Speechmatics APIs

    Package Exports

    • @speechmatics/auth
    • @speechmatics/auth/dist/index.js
    • @speechmatics/auth/dist/index.mjs

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@speechmatics/auth) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Speechmatics authentication 🔑

    Library for managing authentication with Speechmatics APIs

    Table of Contents

    Installation

    npm i @speechmatics/auth

    Usage

    import { RealtimeClient } from '@speechmatics/real-time-client';
    import { createSpeechmaticsJWT } from '@speechmatics/auth';
    
    const client = new RealtimeClient();
    
    client.addEventListener('receiveMessage', ({ data }) => {
      // Handle transcription messages
    });
    
    async function transcribeFileRealtime () {
      const jwt = await createSpeechmaticsJWT({
        type: 'rt',
        apiKey,
        ttl: 60, // 1 minute
      });
    
      const fileStream = fs.createReadStream(
        path.join(__dirname, './example.wav'),
        {
          highWaterMark: 4096, //avoid sending faster than realtime
        },
      );
    
      await client.start(jwt, {
        transcription_config: {
          language: 'en',
          enable_partials: true,
        },
      });
    
      //send it
      fileStream.on('data', (sample) => {
        client.sendAudio(sample);
      });
    
      //end the session
      fileStream.on('end', () => {
        client.stopRecognition();
      });
    }
    
    transcribeFileRealtime();

    Contributing

    Contributions are welcome! Please open an issue or submit a pull request for any changes.

    License

    This project is licensed under the MIT License. See the LICENSE file for details.