55namespace Codewithkyrian \Transformers \Pipelines ;
66
77use Codewithkyrian \Transformers \Models \Auto \AutoModel ;
8+ use Codewithkyrian \Transformers \Models \Auto \AutoModelForAudioClassification ;
89use Codewithkyrian \Transformers \Models \Auto \AutoModelForCausalLM ;
910use Codewithkyrian \Transformers \Models \Auto \AutoModelForImageClassification ;
1011use Codewithkyrian \Transformers \Models \Auto \AutoModelForImageFeatureExtraction ;
@@ -49,6 +50,8 @@ enum Task: string
4950 case ObjectDetection = 'object-detection ' ;
5051 case ZeroShotObjectDetection = 'zero-shot-object-detection ' ;
5152
53+ case AudioClassification = 'audio-classification ' ;
54+
5255
5356 public function pipeline (PretrainedModel $ model , ?PretrainedTokenizer $ tokenizer , ?Processor $ processor ): Pipeline
5457 {
@@ -89,6 +92,8 @@ public function pipeline(PretrainedModel $model, ?PretrainedTokenizer $tokenizer
8992 self ::ObjectDetection => new ObjectDetectionPipeline ($ this , $ model , $ tokenizer , $ processor ),
9093
9194 self ::ZeroShotObjectDetection => new ZeroShotObjectDetectionPipeline ($ this , $ model , $ tokenizer , $ processor ),
95+
96+ self ::AudioClassification => new AudioClassificationPipeline ($ this , $ model , processor: $ processor ),
9297 };
9398 }
9499
@@ -129,16 +134,18 @@ public function defaultModelName(): string
129134 self ::ObjectDetection => 'Xenova/detr-resnet-50 ' , // Original: 'facebook/detr-resnet-50',
130135
131136 self ::ZeroShotObjectDetection => 'Xenova/owlvit-base-patch32 ' , // Original: 'google/owlvit-base-patch32',
137+
138+ self ::AudioClassification => 'Xenova/wav2vec2-base-superb-ks ' , // Original: 'superb/wav2vec2-base-superb-ks',
132139 };
133140 }
134141
135142 public function autoModel (
136- string $ modelNameOrPath ,
137- bool $ quantized = true ,
138- ?array $ config = null ,
139- ?string $ cacheDir = null ,
140- string $ revision = 'main ' ,
141- ?string $ modelFilename = null ,
143+ string $ modelNameOrPath ,
144+ bool $ quantized = true ,
145+ ?array $ config = null ,
146+ ?string $ cacheDir = null ,
147+ string $ revision = 'main ' ,
148+ ?string $ modelFilename = null ,
142149 ?callable $ onProgress = null
143150 ): PretrainedModel
144151 {
@@ -176,13 +183,15 @@ public function autoModel(
176183 self ::ObjectDetection => AutoModelForObjectDetection::fromPretrained ($ modelNameOrPath , $ quantized , $ config , $ cacheDir , $ revision , $ modelFilename , $ onProgress ),
177184
178185 self ::ZeroShotObjectDetection => AutoModelForZeroShotObjectDetection::fromPretrained ($ modelNameOrPath , $ quantized , $ config , $ cacheDir , $ revision , $ modelFilename , $ onProgress ),
186+
187+ self ::AudioClassification => AutoModelForAudioClassification::fromPretrained ($ modelNameOrPath , $ quantized , $ config , $ cacheDir , $ revision , $ modelFilename , $ onProgress ),
179188 };
180189 }
181190
182191 public function autoTokenizer (
183- string $ modelNameOrPath ,
184- ?string $ cacheDir = null ,
185- string $ revision = 'main ' ,
192+ string $ modelNameOrPath ,
193+ ?string $ cacheDir = null ,
194+ string $ revision = 'main ' ,
186195 ?callable $ onProgress = null
187196 ): ?PretrainedTokenizer
188197 {
@@ -191,7 +200,8 @@ public function autoTokenizer(
191200 self ::ImageClassification,
192201 self ::ImageToImage,
193202 self ::ImageFeatureExtraction,
194- self ::ObjectDetection => null ,
203+ self ::ObjectDetection,
204+ self ::AudioClassification => null ,
195205
196206
197207 self ::SentimentAnalysis,
@@ -214,10 +224,10 @@ public function autoTokenizer(
214224 }
215225
216226 public function autoProcessor (
217- string $ modelNameOrPath ,
218- ?array $ config = null ,
219- ?string $ cacheDir = null ,
220- string $ revision = 'main ' ,
227+ string $ modelNameOrPath ,
228+ ?array $ config = null ,
229+ ?string $ cacheDir = null ,
230+ string $ revision = 'main ' ,
221231 ?callable $ onProgress = null
222232 ): ?Processor
223233 {
@@ -229,7 +239,8 @@ public function autoProcessor(
229239 self ::ZeroShotImageClassification,
230240 self ::ImageToImage,
231241 self ::ObjectDetection,
232- self ::ZeroShotObjectDetection => AutoProcessor::fromPretrained ($ modelNameOrPath , $ config , $ cacheDir , $ revision , $ onProgress ),
242+ self ::ZeroShotObjectDetection,
243+ self ::AudioClassification => AutoProcessor::fromPretrained ($ modelNameOrPath , $ config , $ cacheDir , $ revision , $ onProgress ),
233244
234245
235246 self ::SentimentAnalysis,
0 commit comments