audio troubles changing from one to another (stop it consistently changing)

so i have this code and the clip keeps changing , basically i need it to finish playing the clip until the person stops moving forward and starts being idle at which point it needs to change to the idle sound effects without constantly changing the idle sound effect(just to be clear both idle sound effect clips and walking effect clips keep changing so i get literally a frames sound from the clip before it changes to another)

they also need to loop.

thanks for any help in advance !
using UnityEngine;

using System.Collections;

public class fxs : MonoBehaviour {

public GameObject player;
public bool reset = false;
public AudioClip[] walk;
public AudioClip[] idle;


// Use this for initialization
void Start () {
	player = GameObject.FindGameObjectWithTag("Player");
}

// Update is called once per frame
void Update () {
	
	PickFx();
}

void PickFx() {
	TP_Animator other = player.GetComponent<TP_Animator>();
	if(other.walking == true){
		//problem is here 
			audio.clip = walk[Random.Range(0, walk.Length)];
			audio.Play();
				
	
	}
	else if(other.walking == false)
	{
		audio.clip = idle[Random.Range(0, idle.Length)];
			audio.Play();
	}	
}

}

it changes constantly because walking is constantly returning true so i keep getting it changing clip same with if false(idle sounds) im aware i put pickfx in update but i dont know where else to put it if there is one.

You could either wait for the current sound to end before playing a new one, or wait for some delay. Let’s use the delay in the walking state, and the other alternative in the idle case:

float stepTime = 0;
float stepInterval = 0.3f;

void PickFx() {
    TP_Animator other = player.GetComponent();
    if(other.walking == true){ // if walking...
         if (Time.time >= stepTime){ // and stepTime has come...
             audio.clip = walk[Random.Range(0, walk.Length)];
             audio.Play(); // play the walk sound...
             stepTime = Time.time + stepInterval; // and set new stepTime
         }
    }
    else // if not walking...
    {
        if (audio.isPlaying == false){ // and previous sound has finished...
            audio.clip = idle[Random.Range(0, idle.Length)];
            audio.Play(); // play random idle sound
        }
    }  
}

The interval approach is better for footstep sounds - you can even change stepInterval according to the character speed - while the other alternative is better for generating a continuous random sequence of sounds.