Added config fields

Updated voicemod library
Updated actions to be more reliable
This commit is contained in:
2023-11-20 23:41:24 -05:00
parent 8228396309
commit d1ef607952
3 changed files with 27 additions and 18 deletions

View File

@@ -7,13 +7,13 @@ module.exports = function (self) {
id: 'voiceId', id: 'voiceId',
type: 'dropdown', type: 'dropdown',
label: 'Voice', label: 'Voice',
default: 0, default: self.vm.voices[0].id,
choices: self.vm.voices.map((item) => ({ id: item.id, label: item.name })), choices: self.vm.voices.map((item) => ({ id: item.id, label: item.name })),
}, },
], ],
callback: async (event) => { callback: async (event) => {
const voiceId = event.options.voiceId const voiceId = event.options.voiceId
self.vm.voices[voiceId].load() self.vm.internal.setVoice(voiceId)
}, },
}, },
set_beep_sound: { set_beep_sound: {
@@ -40,25 +40,18 @@ module.exports = function (self) {
play_meme: { play_meme: {
name: 'Play Meme', name: 'Play Meme',
options: [ options: [
{
id: 'soundboardId',
type: 'dropdown',
label: 'Soundboard',
default: 0,
choices: self.vm.soundboards.map((item) => ({ id: item.id, label: item.name })),
},
{ {
id: 'memeId', id: 'memeId',
type: 'dropdown', type: 'dropdown',
label: 'Meme', label: 'Meme',
default: 0, default: 0,
choices: self.vm.soundboards.flat().map((item) => ({ id: item.id, label: item.name })),
}, },
], ],
callback: async (event) => { callback: async (event) => {
console.log('in callback!') // console.log('in callback!')
const soundboardId = event.options.soundboardId
const memeId = event.options.memeId const memeId = event.options.memeId
self.vm.soundboards[soundboardId][memeId].play() self.vm.internal.playMeme(memeId)
}, },
}, },
stop_all_sounds: { stop_all_sounds: {

26
main.js
View File

@@ -18,7 +18,7 @@ class ModuleInstance extends InstanceBase {
this.log('debug', 'init called') this.log('debug', 'init called')
this.updateStatus(InstanceStatus.Connecting) this.updateStatus(InstanceStatus.Connecting)
this.vm = new VoiceMod() this.vm = new VoiceMod(this.config.host, this.config.apiKey === '' ? 'anyClient' : this.config.apiKey)
try { try {
this.vm.init().then( this.vm.init().then(
async () => { async () => {
@@ -49,15 +49,31 @@ class ModuleInstance extends InstanceBase {
// Return config fields for web config // Return config fields for web config
getConfigFields() { getConfigFields() {
return [] return [
{
id: 'host',
type: 'textinput',
label: 'Host address',
tooltip: 'Enter the IP/Hostname for the voicemod instance',
default: '127.0.0.1',
},
{
id: 'apiKey',
type: 'textinput',
label: 'API Key',
tooltip: 'Enter your developer API Key for voicemod (not required for now)',
default: '',
},
]
} }
updateActionsFeedbacksVariables() { updateActionsFeedbacksVariables() {
// this.organizeChoices()
this.updateActions() // export actions this.updateActions() // export actions
// this.updateFeedbacks() // export feedbacks // this.updateFeedbacks() // export feedbacks
// this.updateVariableDefinitions() // export variable definitions this.updateVariableDefinitions() // export variable definitions
this.subscribeActions()
// this.subscribeFeedbacks()
// this.checkFeedbacks() // this.checkFeedbacks()
} }

View File

@@ -12,7 +12,7 @@
}, },
"dependencies": { "dependencies": {
"@companion-module/base": "~1.5.1", "@companion-module/base": "~1.5.1",
"voicemod": "^0.1.4", "voicemod": "^0.1.5",
"ws": "^8.14.2" "ws": "^8.14.2"
}, },
"devDependencies": { "devDependencies": {