تتيح لك مهمة "تصنيف المحتوى الصوتي" من MediaPipe تصنيف المقاطع الصوتية إلى مجموعة من
الفئات المحدّدة، مثل موسيقى الغيتار أو صافرة القطار أو أغنية الطيور. يتم تحديد
الفئات أثناء تدريب النموذج. تعمل هذه المهمة على
البيانات الصوتية باستخدام نموذج تعلُّم آلي (ML) كمقطع صوتي مستقل أو مجرى بث باستمرار، وتُخرج قائمة بالفئات المحتمَلة مرتّبة حسب
نتيجة الاحتمالية التنازلية.
ابدأ استخدام هذه المهمة باتّباع أحد أدلة التنفيذ هذه ل منصّتك المستهدفة. ترشدك هذه الأدلة الخاصة بالنظام الأساسي إلى تنفيذ أساسي
لهذه المهمة، بما في ذلك نموذج مقترَح ومثال على الرمز المبرمَج
مع خيارات الإعداد المقترَحة:
ترشدك هذه الأدلة الخاصة بالنظام الأساسي إلى تنفيذ أساسي لهذه ال tâche، بما في ذلك نموذج مقترَح ومثال على الرمز البرمجي مع خيارات الإعداد المقترَحة.
تفاصيل المهمة
يصف هذا القسم ميزات هذه المهمة ومدخلاتها ومخرجاتها وخيارات الضبط.
الميزات
معالجة الصوت المُدخل: تشمل المعالجة إعادة تحليل الصوت
والتخزين المؤقت والإطارات وتحويل فورييه.
لغة خريطة التصنيف: يمكنك ضبط اللغة المستخدَمة للأسماء المعروضة.
الحدّ الأدنى للنتيجة: فلترة النتائج استنادًا إلى نتائج التوقّعات
اكتشاف أهم k رقم: فلترة نتائج رصد الأرقام
تصنيف القائمة المسموح بها وقائمة الحظر: حدِّد الفئات التي تم رصدها.
مدخلات المهام
نتائج المهام
يمكن أن يكون الإدخال أحد أنواع البيانات التالية:
مقاطع صوتية
البث الصوتي
تُصدِر ميزة "تصنيف المحتوى الصوتي" قائمة بالفئات التي تتضمّن ما يلي:
فهرس الفئة: فهرس الفئة في نواتج النموذج
النتيجة: نتيجة الثقة لهذه الفئة، وعادةً ما تكون احتمالية ضمن النطاق [0,1]
اسم الفئة (اختياري): اسم الفئة كما هو محدّد في البيانات الوصفية لنموذج TFLite، إن توفّرت
الاسم المعروض للفئة (اختياري): اسم معروض للفئة كما هو محدّد في البيانات الوصفية لطراز TFLite، باللغة المحدّدة من خلال خيارات لغات الأسماء المعروضة، إن توفّرت
خيارات الإعدادات
تتضمّن هذه المهمة خيارات الضبط التالية:
اسم الخيار
الوصف
نطاق القيمة
القيمة التلقائية
running_mode
لضبط وضع التشغيل للمهمة يتضمّن "تصنيف الصوت" وضعَين:
AUDIO_CLIPS: وضع تشغيل مهمة الصوت على مقاطع صوتية مستقلة.
AUDIO_STREAM: وضع تشغيل مهمة الصوت على بث صوتي، مثل الصوت من الميكروفون في هذا الوضع، يجب
استدعاء resultListener لإعداد مستمع لتلقّي نتائج التصنيف
بشكل غير متزامن.
{AUDIO_CLIPS, AUDIO_STREAM}
AUDIO_CLIPS
display_names_locale
لضبط لغة التصنيفات لاستخدامها في الأسماء المعروضة المقدَّمة في
البيانات الوصفية لنموذج المهمة، في حال توفّرها. القيمة التلقائية هي en لعبارة
English. يمكنك إضافة تصنيفات مترجَمة إلى البيانات الوصفية لنموذج مخصّص
باستخدام واجهة برمجة التطبيقات TensorFlow Lite Metadata Writer API.
رمز اللغة
en
max_results
تُستخدَم لتحديد الحد الأقصى الاختياري لعدد نتائج التصنيف التي ستعرضها. إذا كان < 0، سيتم عرض جميع النتائج المتاحة.
أي أرقام موجبة
-1
score_threshold
تُستخدَم لضبط الحدّ الأدنى لنتيجة التوقّع الذي يتجاوز الحدّ الأدنى المقدَّم في
البيانات الوصفية للنموذج (إن توفّرت). ويتم رفض النتائج التي تقلّ عن هذه القيمة.
[0.0, 1.0]
لم يتم الضبط
category_allowlist
لضبط القائمة الاختيارية لأسماء الفئات المسموح بها. إذا لم تكن فارغة،
سيتم استبعاد نتائج التصنيف التي لا يتضمّن اسم فئتها هذه المجموعة. ويتم تجاهل أسماء الفئات المكرّرة أو غير المعروفة.
هذا الخيار غير متوافق مع الخيار category_denylist، ويؤدي استخدام
كلا الخيارَين إلى حدوث خطأ.
أي سلاسل
لم يتم الضبط
category_denylist
لضبط القائمة الاختيارية لأسماء الفئات غير المسموح بها. إذا كانت هذه المجموعة ليست فارغة، سيتم فلترة نتائج التصنيف التي يكون اسم فئتها في هذه المجموعة. ويتم تجاهل أسماء الفئات المكرّرة أو غير المعروفة. هذا الخيار متناقض
مع الخيار category_allowlist، ويؤدي استخدام كليهما إلى حدوث خطأ.
أي سلاسل
لم يتم الضبط
result_callback
يضبط مستمع النتائج لتلقّي نتائج التصنيف
بشكل غير متزامن عندما يكون "المُصنِّف الصوتي" في وضع تدفق الصوت. لا يمكن استخدامها إلا عند ضبط وضع التشغيل على AUDIO_STREAM
لا ينطبق
لم يتم الضبط
النماذج
يتطلّب "مُصنِّف الصوت" تنزيل نموذج تصنيف صوتي ونقله
إلى دليل مشروعك. ابدأ باستخدام النموذج المُقترَح والمُعدّ بشكلٍ تلقائي للمنصة المستهدَفة عند بدء التطوير باستخدام هذه المهمة. توازن النماذج الأخرى المتاحة عادةً بين
الأداء والدقة ودرجة الدقة ومتطلبات الموارد، وفي بعض الحالات،
تتضمن ميزات إضافية.
نموذج Yamnet (مُقترَح)
نموذج Yamnet هو مصنّف للأحداث الصوتية تم تدريبه على مجموعة بيانات AudioSet لتوقّع أحداث المحتوى الصوتي المحدّدة في بيانات AudioSet. للحصول على معلومات عن أحداث الصوت
التي يتعرّف عليها هذا النموذج، اطّلِع على قائمة تصنيفات النموذج.
في ما يلي مقاييس أداء المهام لعملية المعالجة بأكملها استنادًا إلى نماذج pretrained
المدرَّبة مسبقًا أعلاه. نتيجة وقت الاستجابة هي متوسط وقت الاستجابة على هاتف Pixel 6 باستخدام
وحدة المعالجة المركزية / وحدة معالجة الرسومات.
تاريخ التعديل الأخير: 2025-01-13 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-01-13 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["The MediaPipe Audio Classifier task lets you classify audio clips into a set of defined\ncategories, such as guitar music, a train whistle, or a bird's song. The\ncategories are defined during the training of the model. This task operates on\naudio data with a machine learning (ML) model as independent audio clips or a\ncontinuous stream and outputs a list of potential categories ranked by\ndescending probability score.\n\n[Try it!arrow_forward](https://mediapipe-studio.webapps.google.com/demo/audio_classifier)\n\nGet Started\n\nStart using this task by following one of these implementation guides for your\ntarget platform. These platform-specific guides walk you through a basic\nimplementation of this task, including a recommended model, and code example\nwith recommended configuration options:\n\n- **Android** - [Code example](https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/audio_classifier/android) - [Guide](./android)\n- **Python** - [Code example](https://colab.sandbox.google.com/github/googlesamples/mediapipe/blob/main/examples/audio_classifier/python/audio_classification.ipynb) [Guide](./python)\n- **Web** - [Code example](https://codepen.io/mediapipe-preview/pen/wvxYYmy) - [Guide](./web_js)\n\nThese platform-specific guides walk you through a basic implementation of this\ntask, including a recommended model, and code example with recommended\nconfiguration options.\n\nTask details\n\nThis section describes the capabilities, inputs, outputs, and configuration\noptions of this task.\n\nFeatures\n\n- **Input audio processing** - Processing includes audio resampling, buffering, framing, and fourier transform.\n- **Label map locale** - Set the language used for display names\n- **Score threshold** - Filter results based on prediction scores.\n- **Top-k detection** - Filter the number detection results.\n- **Label allowlist and denylist** - Specify the categories detected.\n\n| Task inputs | Task outputs |\n|----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Input can be one of the following data types: - Audio clips - Audio stream | Audio Classifier outputs a list of categories containing: - Category index: the index of the category in the model outputs - Score: the confidence score for this category, usually a probability in \\[0,1\\] - Category name (optional): the name of the category as specified in the TFLite Model Metadata, if available - Category display name (optional): a display name for the category as specified in the TFLite Model Metadata, in the language specified through display names locale options, if available |\n\nConfigurations options\n\nThis task has the following configuration options:\n\n| Option Name | Description | Value Range | Default Value |\n|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------|---------------|\n| `running_mode` | Sets the running mode for the task. Audio Classifier has two modes: \u003cbr /\u003e AUDIO_CLIPS: The mode for running the audio task on independent audio clips. \u003cbr /\u003e AUDIO_STREAM: The mode for running the audio task on an audio stream, such as from microphone. In this mode, resultListener must be called to set up a listener to receive the classification results asynchronously. | {`AUDIO_CLIPS, AUDIO_STREAM`} | `AUDIO_CLIPS` |\n| `display_names_locale` | Sets the language of labels to use for display names provided in the metadata of the task's model, if available. Default is `en` for English. You can add localized labels to the metadata of a custom model using the [TensorFlow Lite Metadata Writer API](https://ai.google.dev/edge/lite/models/metadata_writer_tutorial#audio_classifiers) | Locale code | en |\n| `max_results` | Sets the optional maximum number of top-scored classification results to return. If \\\u003c 0, all available results will be returned. | Any positive numbers | `-1` |\n| `score_threshold` | Sets the prediction score threshold that overrides the one provided in the model metadata (if any). Results below this value are rejected. | \\[0.0, 1.0\\] | Not set |\n| `category_allowlist` | Sets the optional list of allowed category names. If non-empty, classification results whose category name is not in this set will be filtered out. Duplicate or unknown category names are ignored. This option is mutually exclusive with `category_denylist` and using both results in an error. | Any strings | Not set |\n| `category_denylist` | Sets the optional list of category names that are not allowed. If non-empty, classification results whose category name is in this set will be filtered out. Duplicate or unknown category names are ignored. This option is mutually exclusive with `category_allowlist` and using both results in an error. | Any strings | Not set |\n| `result_callback` | Sets the result listener to receive the classification results asynchronously when the Audio Classifier is in the audio stream mode. Can only be used when running mode is set to `AUDIO_STREAM` | N/A | Not set |\n\n| **Note:** The `resultListener` is dependent on `runningMode`. Only set the `resultListener` when `runningMode` is set to `AUDIO_STREAM`.\n| **Note:** The category allowlist and denylist are mutually exclusive.\n\nModels\n\nThe Audio Classifier requires an audio classification model to be downloaded and\nstored in your project directory. Start with the\ndefault, recommended model for your target platform when you start developing\nwith this task. The other available models typically make trade-offs between\nperformance, accuracy, resolution, and resource requirements, and in some cases,\ninclude additional features.\n| **Attention:** This MediaPipe Solutions Preview is an early release. [Learn more](/edge/mediapipe/solutions/about#notice).\n\nYamnet model (recommended)\n\nThe Yamnet model is an audio event classifier trained on the\n[AudioSet](https://research.google.com/audioset/) dataset to predict audio\nevents defined in the AudioSet data. For information on the audio events\nrecognized by this model, see the model\n[labels list](https://storage.googleapis.com/mediapipe-tasks/audio_classifier/yamnet_label_list.txt).\n\n| Model name | Input shape | Quantization type | Versions |\n|----------------------------------------------------------------------------------------------------------------|-------------|-------------------|----------------------------------------------------------------------------------------------------------------|\n| [YamNet](https://storage.googleapis.com/mediapipe-models/audio_classifier/yamnet/float32/latest/yamnet.tflite) | 1 x 15600 | None (float32) | [Latest](https://storage.googleapis.com/mediapipe-models/audio_classifier/yamnet/float32/latest/yamnet.tflite) |\n\nTask benchmarks\n\nHere's the task benchmarks for the whole pipeline based on the above\npre-trained models. The latency result is the average latency on Pixel 6 using\nCPU / GPU.\n\n| Model Name | CPU Latency | GPU Latency |\n|------------|-------------|-------------|\n| YamNet | 12.29ms | - |"]]