0

I am learning VXML and Django. I am trying to find out how to cleanly retrieve a recording from some voice-xml (vxml) browser and pass it to the server side where I use django to further handle the passed information. Then I want to store the file somewhere in a .wav file to replay it later. I have the following code snippets:

In the VXML file:

   <record name="recording" />
       [here i record the recording]
      <filled>
        <submit next="/url/" method="post" namelist="recording"/>
      </filled>

In the urls.py of django, I would have

  url(r'^url$', view.index, name='index')

The views.index definition

  def index(request):
     _recording = [..retrieve .wav from request here]
     _modelObject = ModelObject(recording= _recording)
     _modelObject.save()     #store recording in some database
     return render(request, 'genericfile.xml', content_type='text/xml')

In the model.py I'd guess I would have a class like:

  from django.db import model

  class ModelObject(model.Models)
       recording = [declare type of .wav file here]

How would I go about completing the steps in the [..] in a clean manner?

Potatoman
  • 23
  • 4

1 Answers1

0

I didn't work with vxml before but look like you want to store both .xml format and .wav format. So here is my solution in this case:

from django.db import model

class ModelObject(model.Models)
    # Define a text filed or anything that can store long string
    # of _recording var above.
    recording = models.TextField() 
    def save(self, *args, **kwargs):
        if self.recording:
            # Convert vxml to wav and store to a file
            pass
        super(ModelObject, self).save(*args, **kwargs)

    @property
    def recording_wav(self):
        if not self.recording:
            return None
        return 'path/to/file.wav' 

Remember use post_delete signal to remove file.wav once an instance of ModelObject is deleted.

Phuong Vu
  • 527
  • 4
  • 16