sending multiple actions to the same void

i’m using a voice recognizer for some spells in a game and i try to add a new command for every element in the list elements but wen the voice recognizer recognizes a elements name it gives the error :

KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <9577ac7a62ef43179789031239ba8798>:0)
magicspels.recognized (UnityEngine.Windows.Speech.PhraseRecognizedEventArgs speech) (at Assets/scripts/magicspels.cs:107)
UnityEngine.Windows.Speech.PhraseRecognizer.InvokePhraseRecognizedEvent (System.String text, UnityEngine.Windows.Speech.ConfidenceLevel confidence, UnityEngine.Windows.Speech.SemanticMeaning[] semanticMeanings, System.Int64 phraseStartFileTime, System.Int64 phraseDurationTicks) (at :0)

how can i fix his ?
it redirects all the elements to the same void elementscall()

using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Windows.Speech;
using System.Reflection;

public class magicspels : MonoBehaviour
{
    private KeywordRecognizer keywordRecognizer;
    private Dictionary<string, Action> actions = new Dictionary<string, Action>();
    private bool called;
    private bool generate;
    private string reqword;
    private GameObject Generated;

    public Microphone mic;

    public Transform instatiatePos;
    public float yoffset;
    public GameObject genPrefab;

    public elements[] elementsList;
    public shapes[] shapeList;
   
    float xpos;
    float ypos;
    float zpos;
 
    private void Start()
    {
        actions.Add("system call", systemCall);
        actions.Add("generate", Generate);
        for(int i = 0; i < elementsList.Length; i++)
        {
            actions.Add(elementsList*.name + "    element",Elementcall);*

Debug.Log(“added” + elementsList*.name);*
}
for (int i = 0; i < elementsList.Length; i++)
{
// actions.Add(elementsList*.name, Shapecall);*
}

keywordRecognizer = new KeywordRecognizer(actions.Keys.ToArray());
keywordRecognizer.OnPhraseRecognized += recognized;
keywordRecognizer.Start();
for(int i = 0; i < Microphone.devices.Length; i++)
{
Debug.Log(Microphone.devices*);*
}

xpos = transform.position.x;
ypos = transform.position.y;
zpos = transform.position.z;
}

private void Update()
{
xpos = (transform.position.x + xpos * 10) / 11;
ypos = (transform.position.y + ypos * 10) / 11;
zpos = (transform.position.z + zpos * 10) / 11;
Vector3 realpos = new Vector3(xpos, ypos + yoffset, zpos);
instatiatePos.position = realpos;
}

private void recognized(PhraseRecognizedEventArgs speech)
{
Debug.Log(speech.text);
reqword = speech.text;
actions[speech.text].Invoke();
}
void systemCall()
{
called = true;
}
void Generate()
{
if (called)
{
generate = true;
Debug.Log(“generated prefab”);
Generated = Instantiate(genPrefab,instatiatePos.position,instatiatePos.rotation);
}
}

void Elementcall()
{
if (called)
{
Debug.Log(“called”);
if (generate)
{
Debug.Log(“generated”);
for (int i = 0; i <= elementsList.Length - 1; i ++)
{
Debug.Log(“checking”);
if (elementsList*.name == reqword)*
{
Debug.Log(“check worked”);
Debug.Log("worked " + reqword);
Generated.GetComponent().material = elementsList*.material;*

}
}

}
}
}

[System.Serializable]
public struct elements
{
public string name;
public Material material;
public GameObject height;

}
[System.Serializable]
public struct shapes
{
public string name;
public Mesh shape;
}
}

Most likely you need to make a comprobation test this code

private void recognized(PhraseRecognizedEventArgs speech)
 {
     if(action.ContainsKey(speech.text))
     {
        Debug.Log(speech.text); 
        reqword = speech.text;
        actions[speech.text].Invoke();
     }
     else 
     { 
         Debug.Log("Your dictionary doesnt contain " + speech.text); 
     }
 }

@ xxmariorfer ok it works now thank you so much for the quick respond