- init runs twice since we weren't doing an await on our init call
- variables now update correctly on startup

### Removed
- api key config option is no longer needed as we are just going to use the one key supplied by VoiceMod
This commit is contained in:
2024-01-23 12:22:31 -05:00
parent 41d444e250
commit 619e10d43f

58
main.js
View File

@@ -19,6 +19,7 @@ class ModuleInstance extends InstanceBase {
this.hearMyVoiceEnabled = false this.hearMyVoiceEnabled = false
this.muteEnabled = false this.muteEnabled = false
this.muteMemesEnabled = false this.muteMemesEnabled = false
this.currentVoiceName = ''
} }
sleep(ms) { sleep(ms) {
@@ -31,9 +32,9 @@ class ModuleInstance extends InstanceBase {
do { do {
this.updateStatus(InstanceStatus.Connecting) this.updateStatus(InstanceStatus.Connecting)
this.vm = new VoiceMod(this.config.host, this.config.apiKey === '' ? 'anyClient' : this.config.apiKey) this.vm = new VoiceMod(this.config.host, 'controlapi-pty528000')
try { try {
this.vm.init().then( await this.vm.init().then(
async () => { async () => {
this.vm.internal.on('backgroundEffectsEnabledEvent', (background) => { this.vm.internal.on('backgroundEffectsEnabledEvent', (background) => {
this.backgroundEffectsEnabled = true this.backgroundEffectsEnabled = true
@@ -46,10 +47,12 @@ class ModuleInstance extends InstanceBase {
this.vm.internal.on('voiceChangerEnabledEvent', (data) => { this.vm.internal.on('voiceChangerEnabledEvent', (data) => {
this.voiceChangerEnabled = true this.voiceChangerEnabled = true
this.checkFeedbacks('VoiceChangerState') this.checkFeedbacks('VoiceChangerState')
this.updateVariableDefinitions()
}) })
this.vm.internal.on('voiceChangerDisabledEvent', (data) => { this.vm.internal.on('voiceChangerDisabledEvent', (data) => {
this.voiceChangerEnabled = false this.voiceChangerEnabled = false
this.checkFeedbacks('VoiceChangerState') this.checkFeedbacks('VoiceChangerState')
this.updateVariableDefinitions()
}) })
this.vm.internal.on('hearMySelfEnabledEvent', (data) => { this.vm.internal.on('hearMySelfEnabledEvent', (data) => {
this.hearMyVoiceEnabled = true this.hearMyVoiceEnabled = true
@@ -62,10 +65,12 @@ class ModuleInstance extends InstanceBase {
this.vm.internal.on('muteMicrophoneEnabledEvent', (data) => { this.vm.internal.on('muteMicrophoneEnabledEvent', (data) => {
this.muteEnabled = true this.muteEnabled = true
this.checkFeedbacks('MicMutedState') this.checkFeedbacks('MicMutedState')
this.updateVariableDefinitions()
}) })
this.vm.internal.on('muteMicrophoneDisabledEvent', (data) => { this.vm.internal.on('muteMicrophoneDisabledEvent', (data) => {
this.muteEnabled = false this.muteEnabled = false
this.checkFeedbacks('MicMutedState') this.checkFeedbacks('MicMutedState')
this.updateVariableDefinitions()
}) })
this.vm.internal.on('muteMemeForMeEnabledEvent', (data) => { this.vm.internal.on('muteMemeForMeEnabledEvent', (data) => {
this.muteMemesEnabled = true this.muteMemesEnabled = true
@@ -75,15 +80,36 @@ class ModuleInstance extends InstanceBase {
this.muteMemesEnabled = false this.muteMemesEnabled = false
this.checkFeedbacks('MemesMutedForMeState') this.checkFeedbacks('MemesMutedForMeState')
}) })
this.vm.internal.getVoiceChangerStatus() this.vm.internal.on('getAllSoundboard', (data) => {
this.vm.internal.getBackgroundEffectStatus() this.updateActions()
this.vm.internal.getMuteMicStatus() })
this.vm.internal.getMuteMemeForMeStatus() this.vm.internal.on('voiceLoadedEvent', (data) => {
this.currentVoiceName = data.voiceId
this.updateVariableDefinitions()
})
this.vm.internal.on('getCurrentVoice', (data) => {
this.currentVoiceName = data.voiceId
this.updateVariableDefinitions()
})
this.vm.internal.on('toggleVoiceChanger', (data) => {
this.voiceChangerEnabled = data.value
this.checkFeedbacks('VoiceChangerState')
this.updateVariableDefinitions()
})
this.vm.internal.on('toggleMuteMic', (data) => {
this.muteEnabled = data.value
this.checkFeedbacks('MicMutedState')
this.updateVariableDefinitions()
})
await this.vm.internal.getCurrentVoice()
this.vm.internal.getVoiceChangerStatus()
this.vm.internal.getMuteMicStatus()
this.loaded = true
this.updateStatus(InstanceStatus.Ok) this.updateStatus(InstanceStatus.Ok)
this.updateActionsFeedbacksVariables() this.updateActionsFeedbacksVariables()
this.loaded = true
this.log('debug', 'connected to VM and ready') this.log('debug', 'connected to VM and ready')
}, },
(reason) => { (reason) => {
@@ -120,13 +146,13 @@ class ModuleInstance extends InstanceBase {
tooltip: 'Enter the IP/Hostname for the voicemod instance', tooltip: 'Enter the IP/Hostname for the voicemod instance',
default: '127.0.0.1', default: '127.0.0.1',
}, },
{ // {
id: 'apiKey', // id: 'apiKey',
type: 'textinput', // type: 'textinput',
label: 'API Key', // label: 'API Key',
tooltip: 'Enter your developer API Key for voicemod (not required for now)', // tooltip: 'Enter your developer API Key for voicemod (not required for now)',
default: '', // default: '',
}, // },
] ]
} }
@@ -153,8 +179,8 @@ class ModuleInstance extends InstanceBase {
this.setVariableValues({ this.setVariableValues({
microphoneMuted: this.muteEnabled, microphoneMuted: this.muteEnabled,
voiceChangerStatus: !this.voiceChangerEnabled, voiceChangerStatus: this.voiceChangerEnabled,
voiceSelected: undefined, voiceSelected: this.currentVoiceName,
}) })
} }
} }