posts: automatically tag videos with sound.

Automatically add the `sound` tag if the post has sound. Remove the tag if the post doesn't have sound.

A video is considered to have sound if its peak loudness is greater than -70 dB. The current quietest post
on Danbooru has a peak loudness of -62 dB (post #3470668), but it's possible to have audible sound at
-80 dB or possibly even lower. It's hard to draw a clear line between "silent" and "barely audible".
This commit is contained in:
evazion
2022-11-05 01:02:29 -05:00
parent 4a241ac6b5
commit 28237e2e09
4 changed files with 26 additions and 2 deletions

View File

@@ -402,7 +402,7 @@ class Post < ApplicationRecord
end
def add_automatic_tags(tags)
tags -= %w[incredibly_absurdres absurdres highres lowres flash video ugoira animated_gif animated_png exif_rotation non-repeating_animation non-web_source wide_image tall_image]
tags -= %w[incredibly_absurdres absurdres highres lowres flash video ugoira animated_gif animated_png exif_rotation non-repeating_animation non-web_source wide_image tall_image sound]
if tags.size >= 30
tags -= ["tagme"]
@@ -472,6 +472,7 @@ class Post < ApplicationRecord
tags << "exif_rotation" if media_asset.is_rotated?
tags << "non-repeating_animation" if media_asset.is_non_repeating_animation?
tags << "ai-generated" if media_asset.is_ai_generated?
tags << "sound" if media_asset.has_sound?
tags
end