npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

voice-services-integration

v1.0.16

Published

语音AI服务聚合接口

Downloads

19

Readme

语音AI服务聚合

1.配置说明

微软
AZURE_KEY=
AZURE_REGION=

2.安装

npm i voice-services-integration

3.使用

引入
import { LCVoiceService } from 'voice-services-integration'
文字转语音 TTS
const audioService = LCVoiceService.getService("azure")

const audioData = await audioService.textToSpeech(text, {
    language: "zh",
    format: "mp3"
})
语音转文字 ASR
import { AudioStream, LCVoiceService } from "voice-services-integration";

const vs = LCVoiceService.getService("azure")
const audioStream = new AudioStream()

// 传入一个音频流
vs.speechRecognize(audioStream, {
    language: "zh"
}, (result) => {
    console.log(result)
}).then(result => {
    console.log(result)
})

// 模拟音频流
const stream = createReadStream("test.pcm", { highWaterMark: 1024 * 10 })
let index = 0
stream.on('data', (chunk: Buffer) => {
    index++
    setTimeout(() => {
        audioStream.addAudio(chunk)
    }, index * 10)
    
})

stream.on('end', () => {
    setTimeout(() => {
        audioStream.close()
    }, index * 10)
})
语音翻译(支持同时翻译成多种语言)
import { AudioStream, LCVoiceService } from "voice-services-integration";

const vs = LCVoiceService.getService("azure")
const audioStream = new AudioStream()
vs.speechTranslate(audioStream, {
    from: "zh", // 源语言
    to: ["en", "ko"], // 目标语言
    tts: true // 是否需要语音合成
}, (result) => {
    console.log(result)
    // 识别过程中的识别结果
    // {
    //     language: 'en', // 翻译的语言
    //     type: 'text|audio', // 翻译的类型, 文本或者语音,tts为true的时候会接收语音
    //     text: '床前明月光疑是地上霜。举头望明月低头思故乡。',  // 识别的文本
    //     result: 'The bright moonlight in front of the bed is suspected to be frost on the ground. Raise your head to look at the bright moon and bow your head to think of your hometown.' // 翻译后的文本
    // }

}).then(results => {
    console.log(results)
    // 识别完成后的结果
    // [ 
    //     {
    //         language: 'en', // 翻译的语言
    //         type: 'text', // 翻译的类型,这里只有文本,tts语音需要用callback接收
    //         text: '床前明月光疑是地上霜。举头望明月低头思故乡。',  // 识别的文本
    //         result: 'The bright moonlight in front of the bed is suspected to be frost on the ground. Raise your head to look at the bright moon and bow your head to think of your hometown.' // 翻译后的文本
    //     },
    //     ...
    // ]
})

// 模拟音频流
const stream = createReadStream("test.pcm", { highWaterMark: 1024 * 10 })
let index = 0
stream.on('data', (chunk: Buffer) => {
    index++
    console.log(index)
    setTimeout(() => {
        audioStream.addAudio(chunk)
    }, index * 10)

})

stream.on('end', () => {
    setTimeout(() => {
        audioStream.close()
    }, index * 10)
})