Spaces:
Running
Running
import gradio as gr | |
import torch | |
import torchaudio | |
import librosa | |
import numpy as np | |
def audio_to_pth(audio): | |
# 音声ファイル(ファイルパス)を読み込む | |
y, sr = librosa.load(audio, sr=None) | |
# 音声データをテンソルに変換 | |
tensor = torch.tensor(y) | |
# テンソルを .pth ファイルに保存 | |
output_path = "audio_features.pth" | |
torch.save(tensor, output_path) | |
return output_path | |
# Gradio インターフェースの設定 | |
iface = gr.Interface( | |
fn=audio_to_pth, | |
inputs=gr.Audio(source="upload", type="filepath"), | |
outputs="file", | |
title="Audio to .PTH Converter", | |
description="Upload an audio file to convert it to a .pth file containing audio features." | |
) | |
iface.launch() | |