Forum rules - please read before posting.

Speech audio played for language that shouldn't have any speech audio

Hi there!

Here's the situation: I want my game to support two languages (English and German). The English language have voice acting but the German doesn't. Everything works fine for text, but I'm having problem with the speech audio after the player switches language.

I have a dropdown in the Options menu to specify the language. The following code runs when the player changes a lang in the drop down:

Options.SetLanguage(newLangId);
// Always prints out the expected values (the same lang names)
Debug.Log($"Lang drop changed: lang:{Options.GetLanguageName()} voice:{Options.GetVoiceLanguageName()}");

The problem is that when I play the game in English (which is the default), and then change language to German, the English voice acting is still played (even though all the text is replaced). Possibly this is because I have a blank value for the "Audio AssetBundle Name" for German.

If I restart the game (in German) then no speech audio is played (as it should be). But if I switch to English it is back, and if I switch back to Geman it's still there.

Here's a dump of my Speech settings:
https://1drv.ms/u/s!Amz_vh8OYDX3u_1wgoK2FGa86_w8SQ?e=hKauAl

Thanks!

Comments

  • Possibly this is because I have a blank value for the "Audio AssetBundle Name" for German.

    Correct. If no AssetBundle is supplied, then nothing will be reloaded, and the existing bundle will remain in memory.

    You could either supply an empty AssetBundle, or hook into the OnLoadSpeechAssetBundle event to clear it manually:

    using UnityEngine;
    using AC;
    
    public class ClearVoiceBundle : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnLoadSpeechAssetBundle += OnLoadSpeechAssetBundle; }
    
        private void OnDisable () { EventManager.OnLoadSpeechAssetBundle -= OnLoadSpeechAssetBundle; }
    
        private void OnLoadSpeechAssetBundle (int language)
        {
            if (language != 1)
            {
                KickStarter.runtimeLanguages.CurrentAudioAssetBundle = null;
            }
        }
    
    }
    
  • Thanks, but then it doesn't work when I switch back to English again (due to the if statement on line 617 in RuntimeLanguages checking currentAudioAssetBundleName instead of CurrentAudioAssetBundle).

    I have coded a suggestion for a fix but since it contains some AC code I'll inbox you the solution instead :smile:

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.