audio analysis service
npm install audio-analysis-servicebash
git clone git@github.com:zxdong262/audio-analysis-service.git
#or git clone https://github.com/zxdong262/audio-analysis-service.git
cd audio-analysis-serviceinstall dependencies
yarncreate config
cp .sample.env .env
then edit .env, fill your google credential path
start local server
yarn dev`
Build and Run in production env
`bash
install pm2 first if you wanna use pm2
yarn global add pm2
or
npm i -g pm2build
yarn buildrun production server
yarn prod-serveror use pm2
pm2 start bin/pm2.yml
`Use as service
- /text-analysis?text=text for text analysis, including Sentiment, Syntax, Classification, Entity sentiment.
- /audio-url-to-text transcript audio url to text with google cloud ai.
- /audio-url-analysis for audio url analysis, will transform to flac first, then transcript to text, then use google cloud ai to anlaysis.
`js it('text-analysis', function(done) {
let text = encodeURIComponent('Hi! My name is Joanna. I will read any text you type here')
fetch(
${base}/text-analysis?text=${text}, {
headers: {
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(res => {
expect(!!res.text).equal(true)
done()
})
}) it('audio-url-analysis', function(done) {
fetch(
${base}/audio-url-analysis, {
method: 'post',
body: JSON.stringify({
url: ${base}/sample.mp3,
//set headers for auth when needed
//headers: {}
}),
headers: {
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(res => {
console.log(res)
expect(!!res.text).equal(true)
done()
})
}) it('audio-url-to-text', function(done) {
fetch(
${base}/audio-url-to-text, {
method: 'post',
body: JSON.stringify({
url: ${base}/sample.mp3,
//set headers for auth when needed
//headers: {AuthCode....}
}),
headers: {
'Content-Type': 'application/json'
}
})
.then(res => res.text())
.then(res => {
expect(res).includes('name is')
done()
})
})
`
Use as lib
`bash
npm i audio-analysis-service
``js
import {textAnalysis} from 'audio-analysis-service/dist/text-analysis'
import {speech2text} from 'audio-analysis-service/dist/url2text'
import {toFlac} from 'audio-analysis-service/dist/voice-to-flac'
import urlAnalysis from 'audio-analysis-service/dist/url-analysis'
`Test
`bash
yarn test
``