很简单
1、prompt:你是一个音乐家,请模仿巴赫写一首60秒左右欢快的歌曲,并使用tone.js生成html代码给我
2、复制html代码,打开bfwstudio https://studio.bfw.wiki/Studio/Open/lang/html.html
将代码粘贴进去运行就能听到歌曲了
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Bach-style Happy Song</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tone/14.8.26/Tone.min.js"></script>
</head>
<body>
<h1>Bach-style Happy Song</h1>
<p>Press the button to start the music!</p>
<buttonBfwOnclick="startMusic()">Start Music</button>
<script>
const synth = new Tone.Synth().toDestination();
const melody = [
{ note: "C4", duration: "8n" },
{ note: "D4", duration: "8n" },
{ note: "E4", duration: "8n" },
{ note: "C4", duration: "8n" },
{ note: "C4", duration: "8n" },
{ note: "D4", duration: "8n" },
{ note: "E4", duration: "8n" },
{ note: "C4", duration: "8n" },
{ note: "E4", duration: "8n" },
{ note: "F4", duration: "8n" },
{ note: "G4", duration: "8n" },
{ note: "E4", duration: "8n" },
{ note: "C4", duration: "8n" },
{ note: "G4", duration: "8n" },
{ note: "A4", duration: "8n" },
{ note: "B4", duration: "8n" },
{ note: "C5", duration: "8n" },
];
let index = 0;
function startMusic() {
Tone.Transport.scheduleRepeat(time => {
let { note, duration } = melody[index % melody.length];
synth.triggerAttackRelease(note, duration, time);
index++;
}, "8n");
Tone.Transport.start();
}
</script>
</body>
</html>
网友回复
webpack打包的网页如何通过ai还原源码成单一html代码?
如何将一个任意url的在线网页的html代码及css、js代码输出成一个文本块中?
PyWebIO、Gradio、Streamlit、NiceGUI怎么选择?
如何从视频中直接解析人物动作捕获数据?
openai发布的agentkit与coze扣子、dify等流程搭建智能体有啥不同?
阿里云上的ecs镜像存储还要钱,如何免费下载到本地以后再创建?
如何通过调用大模型api实现输入一个商品图片生成模特展示解说的宣传短片?
qwen千问大模型api如何内置互联网搜索?
YOLO如何结合opencv实现视觉实时摔倒检测?
html中内嵌style与link引入css代码报错的处理机制不同?