Giter Site home page Giter Site logo

yydounai1234 / yami Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 11.89 MB

变声工具,支持音频链接,本地音频,麦克风音频轨的声音处理

Home Page: https://yydounai1234.github.io/Yami/

License: GNU Lesser General Public License v2.1

HTML 1.01% TypeScript 82.26% Vue 16.73%
audiocontext sound-effects typescript

yami's Introduction

Yami

使用 SoundTouch 提供的变声核心逻辑,通过 audioContenxt 将音频资源、音频文件或音频流进行实时变声处理。

本库 wsola 算法以及插值算法借鉴了 SoundTouchJS 中的实现,与 SoundTouchJS 相比本库的优点在于:

  • 1.支持 Typescript
  • 2.支持原生 ESM
  • 3.支持麦克风设备实时变声
  • 4.接口更简洁

缺点在于:

  • 1.不支持变速

由于使用 ScriptProcessorNode 的音频数据输入进行实时变声处理,所以不支持变速功能,如果需要使用到变速功能并且不使用音频流,可以使用 SoundTouchJS

DEMO

git clone [email protected]:yydounai1234/Yami.git
yarn install
yarn dev

安装

NPM

yarn add yami-voice

CDN

<script src="https://cdn.jsdelivr.net/gh/yydounai1234/Yami/dist/Yami.umd.cjs"></script>
<script>
    // ...
</script> 

ESM

<script type="importmap">
  {
    "imports": {
      "Yami": "https://cdn.jsdelivr.net/gh/yydounai1234/Yami/dist/Yami.cjs"
    }
  }
</script>
<script type="module">
    // ...
</script> 

使用方法

  • 初始化类库
const yami = new Yami()
  • 创建音频轨
// 根据 url 地址创建音频轨
const urlTrack = await yami.createURLTrack('/test.mp3')

// 根据 buffer 创建音频轨
const fileBuffer = new ArrayBuffer()
const bufferTrack = await yami.createBufferTrack(fileBuffer)

// 创建设备麦克风输入的音频轨
const microphoneTrack = await yami.createMicrophoneTrack()
  • 设置变调参数
track.pitch = 0.7
  • 开始播放

url / buffer 播放:

track.play()

麦克风播放:

track.play()
document.getElementByID("audio").srcObject = micoPhoneTrack.stream

使用文档

具体的使用文档指南可以查看 Yami

LICENSE

由于部分代码借鉴了 SoundTouchJS,其采用了 LGPL,故本库也采用 LGPL 协议。

yami's People

Contributors

yydounai1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

gclb

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.