Skip to content

Commit d182598

Browse files
jaeyeun97vincentqb
authored andcommitted
Simpler amplitude_to_DB (#367)
* Simpler amplitude_to_DB * flake8
1 parent 9ab5dd7 commit d182598

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

torchaudio/functional.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,7 @@ def amplitude_to_DB(x, multiplier, amin, db_multiplier, top_db=None):
293293
x_db -= multiplier * db_multiplier
294294

295295
if top_db is not None:
296-
new_x_db_max = torch.tensor(
297-
float(x_db.max()) - top_db, dtype=x_db.dtype, device=x_db.device
298-
)
299-
x_db = torch.max(x_db, new_x_db_max)
296+
x_db = x_db.clamp(min=x_db.max().item() - top_db)
300297

301298
return x_db
302299

0 commit comments

Comments
 (0)