Quickstart
flwr new @flwrlabs/sprind-speechReadme
SPRIN-D: Speech Recognition
This Flower App allows you to federate the training of Wav2vec2 models on the LibriSpeech dataset for automatic speech recognition (ASR) with SpeechBrain. By default the ClientApp runnig from a SuperNode will train on a 100h corpus of the LibriSpeech dataset. Aggregated metrics obtained during training and evaluation are logged to your Weight & Biases account if you configure it to do so.
The contents of this Flower App are as follows:
sprind-speech
├── speech_recognition
│ ├── __init__.py
│ ├── client_app.py # Defines your ClientApp
│ ├── server_app.py # Defines your ServerApp
│ ├── strategy.py # Defines a custom strategy for easy logging to W&B
│ ├── librispeech_prepare.py # Prepares LibriSpeech dataset (loading, preprocessing)
│ ├── generate_yaml.py # Generated configuration on-the-fly
│ └── train_sb_wav2vec2.py # Training loop using SpeechBrain
├── pyproject.toml # Project metadata like dependencies and configs
└── README.mdRunning the App
NOTE
This section assumes you have already deployed a Flower Federation with at least two SuperNodes. Please refer to the provided instructions on how to connect SuperNodes to a running SuperLink.
Before running the app, you need to configure it to point to the SuperLink. This is an easy process and only requires you to edit one line in the pyproject.toml in this directory. Concretely, the address field found at the bottom of the file.
[tool.flwr.federations.sprind-federation]
address = "SUPERLINK-CONTROL-ADDRESS" # <--- Replace with the provided SuperLink IP:PORTTo run the app with default settings simply execute this command from the directory where this README.md lives:
# If you know your Weight & Biases token
flwr run . --run-config="wandb-token='<YOUR-WANDB-TOKEN'" --stream
# If you don't have one
flwr run . --streamExpected Output
On the terminal where you execute flwr run from you'll see an output similiar to the one below. Note this output was obtained when running with Weight and Biases (hence the first few log lines with wandb prefix) and in a federation of 2 SuperNodes. By default, each round the ServerApp samples all of the connected SuperNodes for a round of training. By default the app runs for three rounds using a Wav2vec2 model. Nodes that do not have GPU will skip local training. This will be shown as an Error reported back to the ServerApp and shown in the logs (not shown in the logs below).
Loading project configuration...
Success
🎊 Successfully started run 7522963691491767233
INFO : Starting logstream for run_id `7522963691491767233`
INFO : Start `flwr-serverapp` process
wandb: Currently logged in as: YOUR-USERNAME to https://api.wandb.ai. Use `wandb login --relogin` to force relogin
wandb: Tracking run with wandb version 0.23.0
wandb: Run data is saved locally in <YOUR-LOCAL-FS>/speech-recognition/wandb/run-20251125_174027-fnr1s6fq
wandb: Run `wandb offline` to turn off syncing.
wandb: Syncing run 7522963691491767233-ServerApp
wandb: ⭐️ View project at https://wandb.ai/YOUR-USERNAME/sprind-speech
wandb: 🚀 View run at https://wandb.ai/YOUR-USERNAME/sprind-speech/runs/fnr1s6fq
INFO : Starting CustomFedAvg strategy:
INFO : ├── Number of rounds: 3
INFO : ├── ArrayRecord (312.44 MB)
INFO : ├── ConfigRecord (train): {'send-state-dict-diff': False, 'num-fl-rounds': 3}
INFO : ├── ConfigRecord (evaluate): (empty!)
INFO : ├──> Sampling:
INFO : │ ├──Fraction: train (1.00) | evaluate ( 0.00)
INFO : │ ├──Minimum nodes: train (2) | evaluate (0)
INFO : │ └──Minimum available nodes: 2
INFO : └──> Keys in records:
INFO : ├── Weighted by: 'num-iter'
INFO : ├── ArrayRecord key: 'arrays'
INFO : └── ConfigRecord key: 'config'
INFO :
INFO : Initial global evaluation results: {}
INFO :
INFO : [ROUND 1/3]
INFO : configure_train: Sampled 3 nodes (out of 3)
INFO : aggregate_train: Received 3 results and 0 failures
INFO : └──> Aggregated MetricRecord: {'train_loss': 10.927569071451822}
INFO : Global evaluation
INFO : └──> MetricRecord: {}
INFO :
INFO : [ROUND 2/3]
INFO : configure_train: Sampled 3 nodes (out of 3)
INFO : aggregate_train: Received 3 results and 0 failures
INFO : └──> Aggregated MetricRecord: {'train_loss': 10.884378433227539}
INFO : Global evaluation
INFO : └──> MetricRecord: {}
INFO :
INFO : [ROUND 3/3]
INFO : configure_train: Sampled 3 nodes (out of 3)
INFO : aggregate_train: Received 3 results and 0 failures
INFO : └──> Aggregated MetricRecord: {'train_loss': 10.81040604909261}
INFO : Global evaluation
INFO : └──> MetricRecord: {}
INFO :
INFO : Strategy execution finished in 669.14s
INFO :
INFO : Final results:
INFO :
INFO : Global Arrays:
INFO : ArrayRecord (624.852 MB)
INFO :
INFO : Aggregated ClientApp-side Train Metrics:
INFO : { 1: {'train_loss': '1.0928e+01'},
INFO : 2: {'train_loss': '1.0884e+01'},
INFO : 3: {'train_loss': '1.0810e+01'}}
INFO :
INFO : Aggregated ClientApp-side Evaluate Metrics:
INFO : {}
INFO :
INFO : ServerApp-side Evaluate Metrics:
INFO : {0: {}, 1: {}, 2: {}, 3: {}}
INFO :Override Run Config
You can also override the settings for your ClientApp and ServerApp defined in the [tool.flwr.app.config] section of the pyproject.toml. This can be done by extending the list of arguments passed via the --run-config argument to flwr run. For example:
# Run for 5 rounds
flwr run . --run-config="wandb-token='<YOUR-WANDB-TOKEN' num-server-rounds=5" --stream
# Run for 5 rounds with ClientApps doing 2 local epochs of training instead of 1
flwr run . --run-config="wandb-token='<YOUR-WANDB-TOKEN' num-server-rounds=5 local-epochs=2" --stream