Git Product home page Git Product logo

bfsk-speech-recog-stream's Introduction

bfsk-speech-recog-stream

A node.js module implementing a writable audio stream that detects Binary FSK (Frequency-shift keying) for testing purposes

Basically, bfsk is treated as language for speech processing where a frequency is specified to indicate 0 and another frequency is specified to indicate 1.

Then we can generate BFSK tones from text and this stream will detect the frequencies, convert them to binary and then back to text.

Installation

npm i bfsk-speech-recog-stream

Sample Usage

You will need to have some extra modules installed:

npm i bfsk-speech-synth-stream speaker

Then you can try this code:

const Speaker = require('speaker')

const BfskSpeechSynthStream = require('bfsk-speech-synth-stream')
const BfskSpeechRecogStream = require('bfsk-speech-recog-stream')

const zero_freq = 500
const one_freq = 2000

const sampleRate = 8000

const language = `${zero_freq}:${one_freq}`
const voice = '5' // tone_duration

const audioFormat = 1 // LINEAR16

const signed = true

const format = {
  audioFormat,
  channels: 1,
  sampleRate,
  bitDepth: 16,
  signed,
}

const params = {
  text: 'hello, world',
  language,
  voice,
}

const opts = {
  format,
  params,
}

const ss = new BfskSpeechSynthStream(opts)

const sr = new BfskSpeechRecogStream({
  format,
  params: {
    language,
  }
})

const speaker = new Speaker(format)

sr.on('speech', data => {
  console.log(new Date(), 'speech', JSON.stringify(data, null, 2))
})

ss.pipe(sr)
ss.pipe(speaker)

Output:

2024-06-11T00:32:25.174Z speech {
  "transcript": "hello, world",
  "raw": "011010000110010101101100011011000110111100101100001000000111011101101111011100100110110001100100"
}

bfsk-speech-recog-stream's People

Contributors

mayamatakeshi avatar

Watchers

 avatar

bfsk-speech-recog-stream's Issues

Suppress goertzel-stream exception

We occasionally get:

/home/takeshi/src/git/MayamaTakeshi/ws_speech_server/node_modules/goertzel-stream/index.js:51                                                                                          
    if (chunks <= 0) { throw new Error('chunk size too small') }                           
                             ^                                                             
                                                                                           
Error: chunk size too small                                                                
    at GoertzelStream._write (/home/takeshi/src/git/MayamaTakeshi/ws_speech_server/node_modules/goertzel-stream/index.js:51:30)                                                        
    at writeOrBuffer (node:internal/streams/writable:564:12)                               
    at _write (node:internal/streams/writable:493:10)                                                                                                                                  
    at Writable.write (node:internal/streams/writable:502:10)                              
    at BfskSpeechRecogStream._write (/home/takeshi/src/git/MayamaTakeshi/ws_speech_server/node_modules/bfsk-speech-recog-stream/index.js:71:23)                                        
    at writeOrBuffer (node:internal/streams/writable:564:12)                               
    at _write (node:internal/streams/writable:493:10)                                                                                                                                  
    at Writable.write (node:internal/streams/writable:502:10)                              
    at WebSocket.<anonymous> (/home/takeshi/src/git/MayamaTakeshi/ws_speech_server/src/Recoger.bs.js:38:20)                                                                            
    at WebSocket.emit (node:events:531:35)                                                                                                                                             
                                                                                           
Node.js v21.2.0  

I think it is OK to just return if chunks <= 0.

Implement event speech

To be used by ws_speech_server and mrcp_server.
It should aggregate binaries on timeout, convert to ascii string and report.

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.