mirror of
https://github.com/RavenX8/companion-module-voicemod.git
synced 2026-04-04 05:18:53 -04:00
### Added
- new state variables - voicemod connection retry logic ### Fixed - Fix race-condition crash on init for undefined reference ### Changed - Updated voicemod-api to a version that has `sharp` patched out
This commit is contained in:
@@ -7,7 +7,7 @@ module.exports = function (self) {
|
|||||||
id: 'voiceId',
|
id: 'voiceId',
|
||||||
type: 'dropdown',
|
type: 'dropdown',
|
||||||
label: 'Voice',
|
label: 'Voice',
|
||||||
default: self.vm.voices[0].id,
|
default: '',
|
||||||
choices: self.vm.voices.map((item) => ({ id: item.id, label: item.name })),
|
choices: self.vm.voices.map((item) => ({ id: item.id, label: item.name })),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
143
main.js
143
main.js
@@ -9,6 +9,9 @@ class ModuleInstance extends InstanceBase {
|
|||||||
constructor(internal) {
|
constructor(internal) {
|
||||||
super(internal)
|
super(internal)
|
||||||
|
|
||||||
|
this.loaded = false
|
||||||
|
this.failure = 0
|
||||||
|
|
||||||
this.config = {}
|
this.config = {}
|
||||||
this.memes = []
|
this.memes = []
|
||||||
this.backgroundEffectsEnabled = false
|
this.backgroundEffectsEnabled = false
|
||||||
@@ -18,74 +21,84 @@ class ModuleInstance extends InstanceBase {
|
|||||||
this.muteMemesEnabled = false
|
this.muteMemesEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sleep(ms) {
|
||||||
|
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||||
|
}
|
||||||
|
|
||||||
async init(config) {
|
async init(config) {
|
||||||
this.config = config
|
this.config = config
|
||||||
this.log('debug', 'init called')
|
this.log('debug', 'init called')
|
||||||
|
|
||||||
this.updateStatus(InstanceStatus.Connecting)
|
do {
|
||||||
this.vm = new VoiceMod(this.config.host, this.config.apiKey === '' ? 'anyClient' : this.config.apiKey)
|
this.updateStatus(InstanceStatus.Connecting)
|
||||||
try {
|
this.vm = new VoiceMod(this.config.host, this.config.apiKey === '' ? 'anyClient' : this.config.apiKey)
|
||||||
this.vm.init().then(
|
try {
|
||||||
async () => {
|
this.vm.init().then(
|
||||||
this.vm.internal.on('backgroundEffectsEnabledEvent', (background) => {
|
async () => {
|
||||||
this.backgroundEffectsEnabled = true
|
this.vm.internal.on('backgroundEffectsEnabledEvent', (background) => {
|
||||||
this.checkFeedbacks('BackgroundEffectState')
|
this.backgroundEffectsEnabled = true
|
||||||
})
|
this.checkFeedbacks('BackgroundEffectState')
|
||||||
this.vm.internal.on('backgroundEffectsDisabledEvent', (background) => {
|
})
|
||||||
this.backgroundEffectsEnabled = false
|
this.vm.internal.on('backgroundEffectsDisabledEvent', (background) => {
|
||||||
this.checkFeedbacks('BackgroundEffectState')
|
this.backgroundEffectsEnabled = false
|
||||||
})
|
this.checkFeedbacks('BackgroundEffectState')
|
||||||
this.vm.internal.on('voiceChangerEnabledEvent', (data) => {
|
})
|
||||||
this.voiceChangerEnabled = true
|
this.vm.internal.on('voiceChangerEnabledEvent', (data) => {
|
||||||
this.checkFeedbacks('VoiceChangerState')
|
this.voiceChangerEnabled = true
|
||||||
})
|
this.checkFeedbacks('VoiceChangerState')
|
||||||
this.vm.internal.on('voiceChangerDisabledEvent', (data) => {
|
})
|
||||||
this.voiceChangerEnabled = false
|
this.vm.internal.on('voiceChangerDisabledEvent', (data) => {
|
||||||
this.checkFeedbacks('VoiceChangerState')
|
this.voiceChangerEnabled = false
|
||||||
})
|
this.checkFeedbacks('VoiceChangerState')
|
||||||
this.vm.internal.on('hearMySelfEnabledEvent', (data) => {
|
})
|
||||||
this.hearMyVoiceEnabled = true
|
this.vm.internal.on('hearMySelfEnabledEvent', (data) => {
|
||||||
this.checkFeedbacks('HearMyVoiceState')
|
this.hearMyVoiceEnabled = true
|
||||||
})
|
this.checkFeedbacks('HearMyVoiceState')
|
||||||
this.vm.internal.on('hearMySelfDisabledEvent', (data) => {
|
})
|
||||||
this.hearMyVoiceEnabled = false
|
this.vm.internal.on('hearMySelfDisabledEvent', (data) => {
|
||||||
this.checkFeedbacks('HearMyVoiceState')
|
this.hearMyVoiceEnabled = false
|
||||||
})
|
this.checkFeedbacks('HearMyVoiceState')
|
||||||
this.vm.internal.on('muteMicrophoneEnabledEvent', (data) => {
|
})
|
||||||
this.muteEnabled = true
|
this.vm.internal.on('muteMicrophoneEnabledEvent', (data) => {
|
||||||
this.checkFeedbacks('MicMutedState')
|
this.muteEnabled = true
|
||||||
})
|
this.checkFeedbacks('MicMutedState')
|
||||||
this.vm.internal.on('muteMicrophoneDisabledEvent', (data) => {
|
})
|
||||||
this.muteEnabled = false
|
this.vm.internal.on('muteMicrophoneDisabledEvent', (data) => {
|
||||||
this.checkFeedbacks('MicMutedState')
|
this.muteEnabled = false
|
||||||
})
|
this.checkFeedbacks('MicMutedState')
|
||||||
this.vm.internal.on('muteMemeForMeEnabledEvent', (data) => {
|
})
|
||||||
this.muteMemesEnabled = true
|
this.vm.internal.on('muteMemeForMeEnabledEvent', (data) => {
|
||||||
this.checkFeedbacks('MemesMutedForMeState')
|
this.muteMemesEnabled = true
|
||||||
})
|
this.checkFeedbacks('MemesMutedForMeState')
|
||||||
this.vm.internal.on('muteMemeForMeDisabledEvent', (data) => {
|
})
|
||||||
this.muteMemesEnabled = false
|
this.vm.internal.on('muteMemeForMeDisabledEvent', (data) => {
|
||||||
this.checkFeedbacks('MemesMutedForMeState')
|
this.muteMemesEnabled = false
|
||||||
})
|
this.checkFeedbacks('MemesMutedForMeState')
|
||||||
this.vm.internal.getVoiceChangerStatus()
|
})
|
||||||
this.vm.internal.getBackgroundEffectStatus()
|
this.vm.internal.getVoiceChangerStatus()
|
||||||
this.vm.internal.getMuteMicStatus()
|
this.vm.internal.getBackgroundEffectStatus()
|
||||||
this.vm.internal.getMuteMemeForMeStatus()
|
this.vm.internal.getMuteMicStatus()
|
||||||
|
this.vm.internal.getMuteMemeForMeStatus()
|
||||||
|
|
||||||
this.updateStatus(InstanceStatus.Ok)
|
this.updateStatus(InstanceStatus.Ok)
|
||||||
this.updateActionsFeedbacksVariables()
|
this.updateActionsFeedbacksVariables()
|
||||||
|
|
||||||
this.log('debug', 'connected to VM and ready')
|
this.loaded = true
|
||||||
},
|
this.log('debug', 'connected to VM and ready')
|
||||||
(reason) => {
|
},
|
||||||
this.log('debug', reason)
|
(reason) => {
|
||||||
this.updateStatus(InstanceStatus.ConnectionFailure)
|
this.log('debug', reason)
|
||||||
}
|
this.updateStatus(InstanceStatus.ConnectionFailure)
|
||||||
)
|
++this.failure
|
||||||
} catch (e) {
|
}
|
||||||
this.log('debug', e)
|
)
|
||||||
this.updateStatus(InstanceStatus.UnknownError)
|
} catch (e) {
|
||||||
}
|
this.log('debug', e)
|
||||||
|
this.updateStatus(InstanceStatus.UnknownError)
|
||||||
|
++this.failure
|
||||||
|
}
|
||||||
|
if (this.loaded === false) await this.sleep(500)
|
||||||
|
} while (this.loaded === false && this.failure < 5)
|
||||||
}
|
}
|
||||||
// When module gets deleted
|
// When module gets deleted
|
||||||
async destroy() {
|
async destroy() {
|
||||||
@@ -137,6 +150,12 @@ class ModuleInstance extends InstanceBase {
|
|||||||
|
|
||||||
updateVariableDefinitions() {
|
updateVariableDefinitions() {
|
||||||
UpdateVariableDefinitions(this)
|
UpdateVariableDefinitions(this)
|
||||||
|
|
||||||
|
this.setVariableValues({
|
||||||
|
microphoneMuted: this.muteEnabled,
|
||||||
|
voiceChangerStatus: !this.voiceChangerEnabled,
|
||||||
|
voiceSelected: undefined,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "voicemod-api",
|
"name": "voicemod-api",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"format": "prettier -w ."
|
"format": "prettier -w ."
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@companion-module/base": "~1.5.1",
|
"@companion-module/base": "~1.5.1",
|
||||||
"voicemod": "^0.1.6"
|
"voicemod": "git+https://github.com/RavenX8/voicemod-api.git#companion-module-voicemod-api"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@companion-module/tools": "^1.4.1"
|
"@companion-module/tools": "^1.4.1"
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
module.exports = async function (self) {
|
module.exports = async function (self) {
|
||||||
self.setVariableDefinitions([])
|
self.setVariableDefinitions([
|
||||||
|
{ variableId: 'microphoneMuted', name: 'Microphone Muted' },
|
||||||
|
{ variableId: 'voiceChangerStatus', name: 'Voice Changer Enabled' },
|
||||||
|
{ variableId: 'voiceSelected', name: 'Current Voice Selected' },
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user