Forum rules - please read before posting.

Assigning speech audio file from csv

Hello,

Our workflow requires us to name the speech filenames according to our audio files (instead of auto naming)

Is it possible to assign these filenames(with paths) using speech importer?

csv exporter does not export the filenames so wondered if there is a way to do that

thanks

Comments

  • updating my question:

    instead of using speech importer, is it possible to manually gather speech from selected actionlist asset

    this would be my workflow:

    -Assumimg I created an actionlist asset for every dialogue:speech action

    -i will loop through all actionlists in a folder then assign an id to them (something very high so it wont conflict with other gathered text?)

    -then also assign audio file of that speech to be same as the actionlist asset
  • If you don't opt to rely on auto-naming, speech audio files must currently be directly assigned to their associated entry in the Speech Manager.

    If the audio file exists in your project, it is possible to assign it through script. See, for example, the "AssignAudioManually" function in this wiki script, which attempts to automate the switching between auto-naming and manual-assigning modes of existing lines.

    It is possible to export expected audio files when creating script-sheets, but not when importing/exporting game text CSVs. However, this does sound like a useful ability, so I shall give it some thought.

    I'd prefer this workflow over your second, as I don't recommend attempting to gather single ActionLists / text in isolation, as this can cause issues with repeated IDs, mismatching etc. If we focused back on your first, would that be acceptable?

  • thanks!

    one more question.
    I know ac is using assetbundles but not addressables

    would it be easy to implement it?

    where do you load the resources folder?
    and where should I look for the play function of the loaded resource?

    do you think would it be ok if i just load the addressable asset there and play?

    thanks
  • Resources folders are not used if you rely on asset bundles. But when they are used, AC doesn't load up the whole folder - only the file when its needed.

    In both cases, however, the AudioClip needed is provided by the RuntimeLanguages class's GetSpeechAudioClip function. This is virtualised so it's possible to override through subclassing.

  • edited March 24

    thanks! addressable speech audio works fine

    I switched

    AudioClip clipObj = KickStarter.runtimeLanguages.GetSpeechAudioClip(lineID, speaker);

    with
    AudioClip clipObj = await Addressables.LoadAssetAsync(URL).Task;

    and continued the same process afterwards

    the problem I have is, subtitles does not show up when the audio is found and played. when there is no audio it shows the subtitle. do you have any idea where I messed it up?

    (it shows with the original code, so it's not about subtitle settings)

    I have my subtitles settings on
    unity 2019.3.0f6
    ac 1.70.4

    Thanks

  • Do you have Duplicate for each line? checked in the Menu's properties? Try toggling it.

    If it's checked, the Speech class itself needs to be assigned to the Menu. This is typically handled by the Dialog script's call to AssignSpeechToMenu - but that may not be happening if you've made changes.

    On the topic of addressables: I can confirm that the ability to set custom filenames for speech lines will be a feature of v1.71.0. While I am also looking into potential addressable support, you should at the very least be able to use this custom filename to store the URL - allowing you to override the GetSpeechAudioClip function above, rather than resort to modifying the core Speech class.

  • thanks! going back to dialog script made me realize the speech was returning with empty text as the addressables call is async. so I got the InitSpeech out of the async part and it worked

    same thing for GetSpeechAudioClip function. as the addressable is async I need to await this function and for it I need to have changes in Speech class to have async function right?

    and yes that custom filename will be perfect for us. I was planning on using the description field for that

  • Indeed - the async nature of addressables does make it a little more difficult.

    This would likely be best done by hooking into the custom event system, whereby playing a new speech line triggers the OnStartSpeech event. If you uncheck Auto-play speech audio files? in the Speech Manager, then you can rely solely on custom scripting to handle audio playback.

    Something like this:

    private AudioSource audioSource;
    
    private void OnEnable ()
    {
        EventManager.OnStartSpeech += OnStartSpeech;
        KickStarter.speechManager.searchAudioFiles = false;
    }
    
    private void OnDisable ()
    {
        EventManager.OnStartSpeech -= OnStartSpeech;
    }
    
    private void OnStartSpeech (Char speaker, string text, int lineID)
    {
        audioSource = (speaker != null) ? speaker.speechAudioSource : KickStarter.dialog.GetNarratorAudioSource ();
    
        SpeechLine speechLine = KickStarter.speechManager.GetLine (lineID);
        string filename = speechLine.description; // or GetFilename ();
    
        Addressables.LoadAssetAsync<AudioClip> (filename).Completed += OnCompleteLoad;
    }
    
    private void OnCompleteLoad (AsyncOperationHandle<AudioClip> obj)
    {
        if (obj.Result == null) return;
        audioSource.clip = obj.Result;
        audioSource.loop = false;
        audioSource.Play ();
    }
    
  • oh thank you that is very elegant
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.
Do NOT follow this link or you will be banned from the site!