この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
1 はじめに
昨日、Alexaスキルキットのサウンドライブラリが公開されました。
Announcing the New Alexa Skills Kit Sound Library to Create More Engaging Skills
スキルでは、SSMLにAudioタグを埋め込むことで効果音などを埋め込むことがで簡単にできます。ユニークなサウンドを加えることで、非常に魅力的なUXを簡単に作成することができます。
しかし、インターネットなどで検索できる音源ファイルも通常ライセンスが指定されており、欲しい音が簡単に手に入るとは限りません。
今回発表されたサウンドライブラリは、Alexaスキル用ということで、スキルで使用するのであればライセンスの心配は無いので、探すのであれば、「まず、ここから」と言う選択は悪くないと思います。
2 音源の種類
サウンドライブラリでは、下記の14のカテゴリから数百の音源が提供されています。
- Ambience Sounds(雑踏の雰囲気)
- Animal Sounds(動物)
- Battle Sounds(戦い)
- Cartoon Sounds(漫画)
- Foley Sounds(効果音)
- Home Sounds(家庭)
- Human Sounds(人間)
- Impact Sounds(インパクト)
- Magic Sounds(マジック)
- Musical Sounds(ミュージカル)
- Nature Sounds(自然)
- Office Sounds (オフィス)
- SciFi Sounds(サイエンスフィクション アラームなど)
- Transportation Sounds(交通 バス・車など)
各カテゴリヘは、下記のページからたどることが出来ます。
https://developer.amazon.com/ja/docs/custom-skills/ask-soundlibrary.html
3 使用方法
レスポンスにaudioタグを使用してライブラリのURLを指定するだけです。
const outpu = "ドラムの音を再生します。<audio src='https://s3.amazonaws.com/ask-soundlibrary/musical/amzn_sfx_drum_and_cymbal_01.mp3'/>";
this.emit(':tell',output);
各ライブラリでは、音を再生するUIとSSMLで使用するタグが紹介されていますので、そのままコピーして使用できます。
4 使ってみた
簡単なスキルを作成して、音源を作成してみました。
コードは以下のとおりです。
'use strict';
const Alexa = require('alexa-sdk');
exports.handler = function(event, context, callback) {
const alexa = Alexa.handler(event, context);
alexa.registerHandlers(handlers);
alexa.execute();
};
const animal_1 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/animals/amzn_sfx_bear_groan_roar_01.mp3'/>";
const animal_2 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/animals/amzn_sfx_bird_chickadee_chirps_01.mp3'/>";
const animal_3 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/animals/amzn_sfx_cat_angry_meow_1x_02.mp3'/>";
const battle_1 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/battle/amzn_sfx_battle_man_grunts_01.mp3'/>";
const battle_2 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/battle/amzn_sfx_battle_men_grunts_01.mp3'/>";
const battle_3 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/battle/amzn_sfx_battle_yells_men_run_01.mp3'/>";
const impact_1 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/impacts/amzn_sfx_fireworks_whistles_01.mp3'/>";
const impact_2 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/impacts/amzn_sfx_punch_01.mp3'/>";
const impact_3 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/impacts/amzn_sfx_punch_03.mp3'/>";
const magic_1 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/magic/amzn_sfx_fairy_melodic_chimes_01.mp3'/>";
const magic_2 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/magic/amzn_sfx_ghost_spooky_01.mp3'/>";
const magic_3 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/magic/amzn_sfx_magic_blast_1x_01.mp3'/>";
const musical_1 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/musical/amzn_sfx_bell_med_chime_02.mp3'/>";
const musical_2 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/musical/amzn_sfx_bell_timer_01.mp3'/>";
const musical_3 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/musical/amzn_sfx_buzzer_small_01.mp3'/>";
const nature_1 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/nature/amzn_sfx_lightning_strike_01.mp3'/>";
const nature_2 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/nature/amzn_sfx_ocean_wave_surf_01.mp3'/>";
const nature_3 = "<audio src='https://s3.amazonaws.com/ask-soundlibrary/nature/amzn_sfx_small_stream_02.mp3'/>";
var handlers = {
'Unhandled': function () {
this.emit('LaunchRequest');
},
'LaunchRequest': function () {
this.emit(':ask', '音源のサンプルです。何を再生しますか。');
},
'AnimalIntent': function () {
this.emit('Play', '動物', animal_1, animal_2, animal_3)
},
'BattleIntent': function () {
this.emit('Play', '戦い', battle_1, battle_2, battle_3)
},
'ImpactIntent': function () {
this.emit('Play', 'インパクト', impact_1, impact_2, impact_3)
},
'MagicIntent': function () {
this.emit('Play', 'マジック', magic_1, magic_2, magic_3)
},
'MusicalIntent': function () {
this.emit('Play', 'ミュージカル', musical_1, musical_2, musical_3)
},
'NatureIntent': function () {
this.emit('Play', '自然', nature_1, nature_2, nature_3)
},
'AMAZON.CancelIntent': function () {
this.emit(':tell', '終わります');
},
'AMAZON.StopIntent': function () {
this.emit(':tell', '終わります');
},
'Play': function (target, audio_1, audio_2, audio_3) {
let output = audio_1;
output += audio_2;
output += audio_3;
output += "次はどうしますか。";
this.emit(':ask', output);
},
};
5 最後に
今回は、新しく公開されたサウンドのライブラリを試してみました。
最初に触れたとおりライセンスを気にしないで音源を利用できるのは、非常に嬉しいです。 また、Audioタグに指定するための要件(サンプリング周波数、サンプルレートなど)を適合させたり、ファイルをホストするための場所(S3など)を用意する必要もないので、本当に手軽に利用できると思います。