Write a python code that lists all audio files in a directory in seconds.
Here's a python code that lists all audio files in a directory and displays their length in seconds:

import os
import wave
import contextlib

def get_audio_duration(filename):
    with contextlib.closing(wave.open(filename, 'r')) as f:
        frames = f.getnframes()
        rate = f.getframerate()
        duration = frames / float(rate)
        return duration

directory = '/path/to/your/directory'
for filename in os.listdir(directory):
    if filename.endswith(".wav") or filename.endswith(".mp3"):
        filepath = os.path.join(directory, filename)
        duration = get_audio_duration(filepath)
        print(f"{filename}: {duration:.2f} seconds")

This code loops through all the files in the directory and prints the filename and its duration for audio files with the .wav or .mp3 extension.
Below is an instruction that describes a task. Write a response that appropriately completes the request.

### Instruction:

Write a python code that lists all audio files in a directory in seconds.

### Response:

Here's a python code that lists all audio files in a directory and displays their length in seconds:

import os
import wave
import contextlib

def get_audio_duration(filename):
    with contextlib.closing(wave.open(filename, 'r')) as f:
        frames = f.getnframes()
        rate = f.getframerate()
        duration = frames / float(rate)
        return duration

directory = '/path/to/your/directory'
for filename in os.listdir(directory):
    if filename.endswith(".wav") or filename.endswith(".mp3"):
        filepath = os.path.join(directory, filename)
        duration = get_audio_duration(filepath)
        print(f"{filename}: {duration:.2f} seconds")

This code loops through all the files in the directory and prints the filename and its duration for audio files with the .wav or .mp3 extension.
