Browse Source
        
      
      Remove torchaudio
      
        Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
      
      
        main
      
      
     
    
    
    
	
		
			
				 1 changed files with 
0 additions and 
21 deletions
			 
			
		 
		
			
				- 
					
					
					 
					vggish_input.py
				
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -23,8 +23,6 @@ import resampy | 
			
		
	
		
			
				
					|  |  |  | import mel_features | 
			
		
	
		
			
				
					|  |  |  | import vggish_params | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import torchaudio | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | def waveform_to_examples(data, sample_rate, return_tensor=True): | 
			
		
	
		
			
				
					|  |  |  |     """Converts audio waveform into an array of examples for VGGish. | 
			
		
	
	
		
			
				
					|  |  | @ -78,22 +76,3 @@ def waveform_to_examples(data, sample_rate, return_tensor=True): | 
			
		
	
		
			
				
					|  |  |  |             log_mel_examples, requires_grad=True)[:, None, :, :].float() | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     return log_mel_examples | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | def wavfile_to_examples(wav_file, return_tensor=True): | 
			
		
	
		
			
				
					|  |  |  |     """ | 
			
		
	
		
			
				
					|  |  |  |     Convenience wrapper around waveform_to_examples() for a common WAV format. | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     Args: | 
			
		
	
		
			
				
					|  |  |  |         wav_file: | 
			
		
	
		
			
				
					|  |  |  |             String path to a file, or a file-like object. | 
			
		
	
		
			
				
					|  |  |  |             The file is assumed to contain WAV audio data with signed 16-bit PCM samples. | 
			
		
	
		
			
				
					|  |  |  |         return_tensor: | 
			
		
	
		
			
				
					|  |  |  |             Return data as a Pytorch tensor ready for VGGish | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |   Returns: | 
			
		
	
		
			
				
					|  |  |  |     See waveform_to_examples. | 
			
		
	
		
			
				
					|  |  |  |   """ | 
			
		
	
		
			
				
					|  |  |  |     data, sr = torchaudio.load(wav_file) | 
			
		
	
		
			
				
					|  |  |  |     wav_data = data.detach().numpy().transpose() | 
			
		
	
		
			
				
					|  |  |  |     return waveform_to_examples(wav_data, sr, return_tensor) | 
			
		
	
	
		
			
				
					|  |  | 
 |