I’ve written audio_conversion(request)
function in views.py to get custom object/method from model.py. But I don’t know if this the best way.
Model.py
class DemoMCall(models.Model):
tenant_name = models.CharField(max_length=200)
rid = models.PositiveBigIntegerField(primary_key=True)
audio_file = models.FileField( upload_to = 'uploads/' )
def get_path_audio(self):
return self.audio_file
And I call it from a views.py like this:
def audio_conversion(request):
file = "C:\\Users\\Downloads\\Recordings\\sox\\Recordings"
# Get audio path
rec_lis = DemoMCall.objects.all()
for i in rec_lis:
name_file = i.get_path_audio()
full_path_infile = file + name_file + ".ul" # -> the input
full_path_outfile = file + name_file + ".wav" # -> the output
if os.path.isfile(full_path_infile):
command2 = " D:\\Quality-Management-main\\sox-14-4-2\\sox " + full_path_infile + full_path_outfile + " rate -v 8000"
output = os.popen(command2)
else:
continue
return render(request, 'qualityManagement/command.html' , {'output' : output} )
Any ideas on what I do to solve this ? Thanks for help!