audiojs / audio-decode Goto Github PK
View Code? Open in Web Editor NEWMinimal audio decoders layer
License: MIT License
Minimal audio decoders layer
License: MIT License
Receiving an MP3 buffer from Google Cloud Text-to-speech API and I cannot seem to be able to play it back.
console.log("Synthesizing...");
const [speech] = await this.client.synthesizeSpeech(request);
console.log("Synthesized: ", speech);
console.log("Decoding...");
const audioBuffer = await decode(speech.audioContent);
console.log(`Decoded: ${audioBuffer}`);
console.log("Playing...");
await play(audioBuffer, {
autoplay: true,
});
I get this error:
Synthesizing...
Synthesized: { audioContent: <Buffer ff f3 44 c4 00 00 00 03 48 01 40 00 00 f0 1a 72 01 46 bc 0d 51 20 39 07 bc 63 44 a1 f8 1c 08 20 c3 df e0 6c 10 58 60 80 00 31 8f fc 03 46 18 5c 1b 16 ... > }
Decoding...
(node:4404) UnhandledPromiseRejectionWarning: Error: Cannot detect audio format of buffer
If ready pcm data passed, for example.
How to do that?
audio-decode/stream
should decode input pcm data by chunks, if it is possible, or as a single piece if not.
It is important to make it compatible with other stream-based components.
Right now it is just a stub package for browser, using decodeAudioData.
The main and the most important part is make it work in node.
Since m4a (audio-only MPEG-4) is a very common format for audio files, it would be a helpful improvement if audio-decode supports m4a.
I would like to convert a voice recorded blob to mp3, does this library provide that? I have gone through the docs and its not quite clear
const decode = require('audio-decode')
decode(fs.readFileSync('./path/to/song.mp3'))
.then(console.log)
.catch(console.error)
It hangs for me. How to trouble-shoot?
Branch | Build failing π¨ |
---|---|
Dependency | audio-play |
Current Version | 2.1.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As audio-play is βonlyβ a devDependency of this project it might not break production or downstream projects, but βonlyβ your build or test tools β preventing new deploys or publishes.
I recommend you give this issue a high priority. Iβm sure you can resolve this πͺ
The new version differs by 5 commits.
f9bc31a
2.2.0
e0b4f93
Update readme typos
ea446b3
Update badge
cd7515e
Add tags
bef89dc
Fix browser/node deps and playback
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
does it exists, how do you use this in a typescript project ?
Is there any chance I can use it in a React project? Can't figure it out how to make it work for a while.
For now it is mixed if plain buffer is passed
My audio-decode version: 2.1.1
My MP3 file: test.zip
My code:
const fs = require('fs').promises;
async function main(options) {
const audioDecode = await import('audio-decode');
const decode = audioDecode.default;
await audioDecode.decoders.mp3();
const buffer = fs.readFile('test.mp3');
const decodedBuffer = await decode(buffer);
}
main().catch(console.error)
I get the following error:
Error: Cannot detect audio format
at audioDecode (file:///home/fedora/test/node_modules/audio-decode/audio-decode.js:17:19)
at main (/home/fedora/test/test.js:8:33)
Hi, when adding that repo to my TypeScript based NodeJS server, I get this error:
Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/audio-decode/audio-decode.js from .../apps/backend/main.js not supported.
Instead change the require of audio-decode.js in .../apps/backend/main.js to a dynamic import() which is available in all CommonJS modules.
I tried all possible ways of importing the module, like this:
import * as decode from 'audio-decode';
import decode from 'audio-decode';
import {decodeAudio} from 'audio-decode';
I always get the same error.
My tsconfig.json looks like this:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node"],
"emitDecoratorMetadata": true,
"target": "es2015"
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}
What can I do to use that package?
Right now callback is invoked with inconventional args: cb(buffer)
.
I guess we should pass error as a first argument.
This package is urgently useless now. If nothing changes in the following year, scrap that.
Hi I am using this decoder and it works well overall. I have a minor issue when I change decoding types. If I use different decoder decoder can't work stops working for certain file types. Until I reload the app. I thought unloading the resources but I didn't find this functionality.
Steps to reproduce the issue.
1-) Run decoder.flac() -> To load flac format.
2-) Run decoder.flac(flacFile) -> I decoded a flac file and it worked well
3-) Run decoder.mp3() -> It looks like working and loading mp3
4-) Run decoder.mp3(mp3File) -> Decoder crashes and not working gives this error in console.
Error:
DOMException: Failed to construct 'AudioBuffer': The number of frames provided (0) is less than or equal to the minimum bound (0).
If I only try to step 3 and 4 it successfuly encodes mp3 file.
Thank you for this awesome library.
It's not documented very well on MDN, but it looks like you can pass a second callback for error handling:
ctx.decodeAudioData(arraybuffer, function(audiobuffer) {
// success
}, function(error) {
// error
});
Branch | Build failing π¨ |
---|---|
Dependency | audio-lena |
Current Version | 1.1.2 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As audio-lena is βonlyβ a devDependency of this project it might not break production or downstream projects, but βonlyβ your build or test tools β preventing new deploys or publishes.
I recommend you give this issue a high priority. Iβm sure you can resolve this πͺ
The new version differs by 7 commits.
f709b66
1.1.3
176a0c7
Remove greenkeeper
eb21a39
Explain example better
d502bb9
Add spec table
efdebef
Merge pull request #4 from audiojs/greenkeeper/initial
66b1414
docs(readme): add Greenkeeper badge
7041c5a
chore(package): update dependencies
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.