首先介绍什麽是 Teachable Machine,
Teachable Machine 是一个网页工具,让程序设计师将机械学习的专业知识及如何撰写机械学习的程序码抛到脑後的情况下,
还能简单地为网站应用程序训练机器学习模型。(https://www.ithome.com.tw/news/134117)
接着备料,
等待上传完成後,画面会变成如下所示。(点选 Copy,并请先贴到其他地方,如:记事本)
11. 在 hello-ml5 里新增两个档案,一档名为 voice.html,另一档名为 sketch_voice.js,在 voice.html 与 sketch_voice.js 分别输入以下程序码。
voice.html 的程序码如下—
<html>
<head>
<meta charset="UTF-8">
<title>Sound classification using pre-trained custom model</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.dom.min.js"></script>
<script src="https://unpkg.com/ml5@latest/dist/ml5.min.js" type="text/javascript"></script>
</head>
<body>
<h1>Sound classification using pre-trained custom model</h1>
<script src="sketch_voice.js"></script>
</body>
</html>
sketch_voice.js 的程序码如下—
// Global variable to store the classifier
let classifier;
// Label
let label = 'listening...';
// Teachable Machine model URL:
let soundModel = '**此处贴上刚才复制在记事本上的URL**';
const options = { includeEmbedding: true };
function preload() {
// Load the model
classifier = ml5.soundClassifier(soundModel + 'model.json', options);
}
function setup() {
createCanvas(320, 240);
// Start classifying
// The sound model will continuously listen to the microphone
classifier.classify(gotResult);
}
function draw() {
background(0);
// Draw the label in the canvas
fill(255);
textSize(32);
textAlign(CENTER, CENTER);
text(label, width / 2, height / 2);
}
// The model recognizing a sound will trigger this event
function gotResult(error, results) {
if (error) {
console.error(error);
return;
}
// The results are in an array ordered by confidence.
// console.log(results[0]);
label = results[0].label;
}
备料完成後,就可启动 Live Server,
在 VS Code 里的 voice.html 程序码按右键,在显示的内容选单里,点选 Open with Live Server,
就可显示如下画面。(会先跳出询问是否让此网页有使用麦克风的权限,请按同意)
分别在 Youtube 上开启馆长、彭P 、莹真律师的声音,看黑布上面是否有比较多次显示对应声音的正确名称。
所以,训练士兵 (model) 的演习地点 (Teachable Machine),也可以直接在前线(前端网页)。
https://www.youtube.com/watch?v=TOrVsLklltM
https://ml5js.org/reference/api-soundClassifier/
https://github.com/tensorflow/tfjs-models/tree/master/speech-commands
<<: 零信任即存取控制2.0 (Zero Trust as Access Control 2.0)
Vue:昨日,我们已将文章新增实做出来了!现在只要将文章列举在首页,只需要使用之前学到的v-for回...
资通安全责任等级 依照资通安全责任等级分级办法,由主管机关核定相对应之等级,按照等级决定导入系统之...
整理一下目前做的东西: 目前关於敌人行动还没有实作 但在开始敌人动作之前,想补齐以下议题 技能动画 ...
NVM与NPM虽然差一个字,但两者兼具着不同的工作。 NVM全名Node Version Manag...
**1.安装Visual Studio code ** 有安装的可跳过这一步 官网连结: http:...