Tutorial / チュートリアル¶
This tutorial will teach you the basics of the Wandas library in 5 minutes. このチュートリアルでは、Wandasライブラリの基本的な使い方を5分で学べます。
Installation / インストール¶
pip install wandas
Basic Usage / 基本的な使い方¶
1. Import the Library / ライブラリのインポート¶
import wandas as wd
2. Load Audio Files / 音声ファイルの読み込み¶
# Load a WAV file / WAVファイルを読み込む
url = "https://github.com/kasahart/wandas/raw/v0.1.6/examples/data/summer_streets1.wav"
audio = wd.read_wav(url)
print(f"Sampling rate / サンプリングレート: {audio.sampling_rate} Hz")
print(f"Number of channels / チャンネル数: {audio.n_channels}")
print(f"Duration / 長さ: {audio.duration} s")
Sampling rate / サンプリングレート: 44100 Hz
Number of channels / チャンネル数: 2
Duration / 長さ: 15.0 s
3. Visualize Signals / 信号の可視化¶
# Display waveform / 波形を表示
audio.describe()
4. Basic Signal Processing / 基本的な信号処理¶
# Apply a low-pass filter (passing frequencies below 1kHz)
# ローパスフィルタを適用(1kHz以下の周波数を通過)
filtered = audio.low_pass_filter(cutoff=1000)
# Visualize and compare results
# 結果を可視化して比較
filtered.previous.plot(title="Original")
filtered.plot(title="filtered")
Channel selection with query / チャンネル選択(query 引数)¶
get_channel can select channels using a query argument based on metadata instead of indices or labels. Supported queries:
get_channel はインデックスやラベルの代わりにメタデータを用いた query 引数でチャネルを選択できます。サポートされるクエリ:
str: Exact match for labels / ラベルの完全一致re.Pattern: Regular expression search on labels / ラベルに対する正規表現検索callable(ChannelMetadata) -> bool: Metadata predicate / メタデータ述語dict: Match against attributes ofChannelMetadata(can use regex for values) /ChannelMetadataの属性に対する一致(値に正規表現を使うことも可能)
Example / 例:
import re
# Get channel with label containing "acc" / ラベルに "acc" を含むチャネルを取得
cf.get_channel(0, query=re.compile(r"acc"))
# Get channel with unit 'g' using metadata predicate / メタデータ述語で取得(単位が g のチャネル)
cf.get_channel(0, query=lambda ch: ch.unit == 'g')
# Dict specification: match on model field and channel.extra key / dict 指定: model フィールド と channel.extra のキーでマッチ
cf.get_channel(0, query={"unit": "g", "gain": 0.8})
Note: Keys specified in dict are only allowed for model fields of ChannelMetadata (pydantic) or existing keys in the channel's extra. Passing unknown keys will raise a KeyError.
注意: dict で指定するキーは ChannelMetadata のモデルフィールド(pydantic)または既に存在するチャネルの extra キーのみ許容されます。不明なキーを渡すと KeyError が発生します。
Next Steps / 次のステップ¶
- API Reference / APIリファレンス
- Detailed API specifications.
- 詳細な機能やAPI仕様を調べる。
- Theory Background / 理論背景
- Design philosophy and algorithm explanations.
- ライブラリの設計思想やアルゴリズムを理解する。
Learning Path / 学習パス¶
This section provides links to tutorial notebooks that demonstrate more detailed features and application examples of the Wandas library. このセクションでは、Wandasライブラリのより詳細な機能や応用例を、以下のチュートリアルノートブックを通じて学ぶことができます。
- Learning Path — 00_Why Wandas (Notebook): Overview and motivation / 概要と動機付け
- Learning Path — 01_Getting Started (Notebook): Setup and basic configuration / セットアップと基本的な設定
- Learning Path — 02_Working With Data (Notebook): Reading, inspecting, and simple transformations / 読み込み、検査、基本的な変換