Skip to content

Instantly share code, notes, and snippets.

@ducnh1022
Created February 23, 2026 08:05
Show Gist options
  • Select an option

  • Save ducnh1022/23d2f1f70c221bed4104287b99732e8e to your computer and use it in GitHub Desktop.

Select an option

Save ducnh1022/23d2f1f70c221bed4104287b99732e8e to your computer and use it in GitHub Desktop.
# Most compatible way – use .loc / .iat if DataFrame, indexing if ndarray
loudness = float(features['loudness_sma3_amean'].item()
if hasattr(features, '__getitem__') and 'loudness_sma3_amean' in features
else features[smile.feature_names.index('loudness_sma3_amean')])
voicing_key = 'voicingProb_sma3nz_amean'
voicing = 0.0
if voicing_key in smile.feature_names:
idx = smile.feature_names.index(voicing_key)
voicing = float(features[voicing_key].item()
if hasattr(features, '__getitem__') and voicing_key in features
else features[idx])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment