-
Notifications
You must be signed in to change notification settings - Fork 3
Add effects and add classify music genres function. #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
src/Audio.ts
Outdated
| } | ||
| } | ||
|
|
||
| async classifyGenre(files: File) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 api 的入参是 files 嘛?是不是可以直接用 data 传入的。
| if (files[0]) { | ||
| const wavFile = await this.convertAudio(files[0]); | ||
| this.worker.postMessage(wavFile); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API 设计如下:
import { Audio } from '@antv/a8';
const audio = new Audio();
audio.data(a);
const c = await audio.classifyGenre();不使用 callback 的形式,伪代码这么实现:
async classifyGenre() {
this.worker = new Worker(new URL('./classifyWorker.ts', import.meta.url), { type: 'module' });
return new Promise((resolve, reject) => {
this.worker.onmessage = (event) => {
const { classifyOutput, classifyTime, label } = event.data;
// this.classifyOutput = classifyOutput;
// this.onclassify(label, classifyTime);
resolve({ label, classifyTime, classifyOutput });
};
this.worker.onerror = (e) => {
reject(e);
}
const wavFile = await this.convertAudio(files[0]);
this.worker.postMessage(wavFile);
})
}| self.onmessage = async function (event) { | ||
| const result = await classifyGenre(event.data); | ||
| self.postMessage(result); | ||
| }; No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码风格,用两个空格做缩进。
|
@Aroganta 单元测试报错,看看日志需要解决一下。 |
|
lock 文件删除,并放到 git ignore 中。 |
Delete the lock file and put it in git ignore. |

🤔 This is a
🔗 Related issue link
💡 Background and solution
📝 Changelog
☑️ Self Check before Merge