Ich versuche, einen Librispeech-Datensatz in meinen Code zu importieren und dann damit zu trainieren, erhalte aber immer wieder Folgendes:
audio_features ist leer . Überspringen der LSTM-Vorbereitung.
Die librispeech-Ordner enthalten .txt oben und .flac-Dateien darunter .txt-Dateien. [code]import librosa import os import numpy as np
def load_librispeech_dataset(directory): audio_files = [] labels = [] for root, _, files in os.walk(directory): for file in files: if file.endswith('.flac'): file_path = os.path.join(root, file) try: audio, sr = librosa.load(file_path, sr=None) mfccs = librosa.feature.mfcc(y=audio, sr=sr, n_mfcc=40) audio_files.append(np.mean(mfccs.T, axis=0))
# Assuming the label (transcription) is in a corresponding text file label_path = file_path.replace('.flac', '.txt') with open(label_path, 'r') as label_file: label = label_file.read().strip() labels.append(label) except Exception as e: print(f"Error processing {file_path}: {e}")
return np.array(audio_files), labels # Indentation corrected: Return after processing all files
dataset_directory = 'C:\\Users\\rowro\\Downloads\\train-clean-100\\LibriSpeech\\train-clean-100' audio_features, transcriptions = load_librispeech_dataset(dataset_directory) import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, LSTM, Dropout from tensorflow.keras.utils import to_categorical # Import to_categorical
if audio_features.size == 0: print("audio_features is empty. Skipping LSTM preparation.") else:
audio_features = audio_features.reshape(audio_features.shape[0], 1, audio_features.shape[1]) # Reshape for LSTM
vocabulary = sorted(list(set(transcriptions)))
transcription_to_index = {transcription: index for index, transcription in enumerate(vocabulary)}
indexed_transcriptions = [transcription_to_index[transcription] for transcription in transcriptions]
Ich erhalte gerade ein Problem beim Senden von Daten pro Bild. Das letzte, was manchmal gesendet wird, erscheint manchmal nicht auf dem Gerät. Ich habe das Gefühl, dass es etwas auf der Arduino...
Ich kratze Fußballspiele Ergebnisse und Quotendaten von einer Website, aber wenn ein Fußballspiel keine Chancen hat, möchte ich diese Reihe gerne überspringen. Im Moment, und ich weiß nicht warum,...
Der Code, den ich unten erwähnen werde, erzeugt einen sehr schlechten Ton (output.mp3), wie ich auf elevanlabs getestet habe. Was ist Ihrer Meinung nach der Grund dafür? Gibt es ein Problem mit den...
Ich löse diese Leetcode-Frage „Gleiches Zeilen- und Spaltenpaar“ ( wobei die Die Problembeschreibung lautet
Geben Sie bei einem 0-indizierten n x n ganzzahligen Matrixgitter die Anzahl von zurück...