头图

🎧audio-hacker介绍

你是否想突破网页中视频的音量的限制?或者还原那些被变声过的声音?

audio-hacker 是一个基于谷歌jungle.js封装的ts库,提供了ts类型和音量增益方法,使用方式十分简单。

A magical library for controlling audio pitch and volume, based on jungle.js

安装

npm i audio-hacker

yarn add audio-hacker

pnpm add audio-hacker

初始化 Audiohacker

import Audiohacker from 'audio-hacker';

const audioCtx = new AudioContext();

if (audioCtx.state !== 'running') {
    await audioCtx.resume();
}

const video = document.querySelector('video');

const source = audioCtx.createMediaElementSource(video);

const audioController = new Audiohacker(audioCtx, source);

调整音调


// best step 0.01
audioController.setPitchOffset(0.22);
audioController.setPitchOffset(-0.12);

调整音量


// minimum value is 0;
audioController.setVolume(0.3);
audioController.setVolume(3.3);

断开连接


audioController.disconnect();

更多

If you want to do it in a simpler way, use Video Roll browser extension.


Gomi
2.4k 声望2.3k 粉丝

前端,业余PPT设计师