diff --git a/myproject/myapp/__pycache__/__init__.cpython-310.pyc b/myproject/myapp/__pycache__/__init__.cpython-310.pyc index a599ed25ee03d644228f85ccee265270f04c19bb..90e1f184c1d2610e7cb73615936201cc4d1003a7 100644 Binary files a/myproject/myapp/__pycache__/__init__.cpython-310.pyc and b/myproject/myapp/__pycache__/__init__.cpython-310.pyc differ diff --git a/myproject/myapp/__pycache__/apps.cpython-310.pyc b/myproject/myapp/__pycache__/apps.cpython-310.pyc index 1e73d400192b6ce43f63230e39c8d3eaedcbfa38..78e9148825a43e1980af163b97f9be57b98d0b2e 100644 Binary files a/myproject/myapp/__pycache__/apps.cpython-310.pyc and b/myproject/myapp/__pycache__/apps.cpython-310.pyc differ diff --git a/myproject/myapp/migrations/0001_initial.py b/myproject/myapp/migrations/0001_initial.py new file mode 100644 index 0000000000000000000000000000000000000000..8bf97a1828c19c6390cd48e0d5fe71fede0807d9 --- /dev/null +++ b/myproject/myapp/migrations/0001_initial.py @@ -0,0 +1,21 @@ +# Generated by Django 5.0.1 on 2024-03-04 13:30 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Audio', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('file', models.FileField(upload_to='audio', verbose_name='audio')), + ], + ), + ] diff --git a/myproject/myapp/models.py b/myproject/myapp/models.py index b8208e7a9976a067aa04bcd3a464dd3f9218e6c9..4e65c8beebbdefeeb38ef52cbcd56dd4fff5561a 100644 --- a/myproject/myapp/models.py +++ b/myproject/myapp/models.py @@ -1,4 +1,4 @@ -# from django.db import models +from django.db import models # # Usertypes # # --------- @@ -57,4 +57,5 @@ # data = models.CharField(max_length=2000) # uploader = models.ForeignKey("User", on_delete=models.CASCADE) - +class Audio(models.Model): + file = models.FileField('audio', upload_to='audio') \ No newline at end of file diff --git a/myproject/myapp/static/src/media/G53-44104-1111-00083.wav b/myproject/myapp/static/src/media/G53-44104-1111-00083.wav new file mode 100644 index 0000000000000000000000000000000000000000..16db7104451f5e6bf8f9129cca860dc084db1789 Binary files /dev/null and b/myproject/myapp/static/src/media/G53-44104-1111-00083.wav differ diff --git a/myproject/myapp/templates/_base.html b/myproject/myapp/templates/_base.html index 1c7aff007ef2627b40a3ee484e0dd453d72aaad4..2f934a25e7a9f2df2e633520b35590c7e0a22142 100644 --- a/myproject/myapp/templates/_base.html +++ b/myproject/myapp/templates/_base.html @@ -144,7 +144,7 @@ <span class="text-sm text-gray-500 sm:text-center dark:text-gray-400">© 2024 <a href="https://flowbite.com/" class="hover:underline">DESD Group 25</a>. All Rights Reserved. </span> </div> -</footer> +</footer> </html> diff --git a/myproject/myapp/templates/index1.html b/myproject/myapp/templates/index1.html index 2f1c6636b26e0d772ebfed9122f94de476c5ca7e..6e3f604685dd455c8429972a218241131563e951 100644 --- a/myproject/myapp/templates/index1.html +++ b/myproject/myapp/templates/index1.html @@ -2,7 +2,7 @@ {% block content %} <section class="bg-white dark:bg-gray-900"> - <div class="gap-16 items-center py-8 px-4 mx-auto max-w-screen-xl lg:grid lg:grid-cols-2 lg:py-16 lg:px-6"> + <div class="gap-16 items-center py-8 px-4 mx-auto max-w-screen-xl lg:grid lg:grid-cols-2"> <div class="font-light text-gray-500 sm:text-lg dark:text-gray-400"> <h2 class="mb-4 text-4xl tracking-tight font-extrabold text-gray-900 dark:text-white">An Intelligent System for Instrument Detection</h2> <p class="mb-4">*placeholder input* We present to you a intelligent system for instrument detection. Using audio processing techinques and a convolutionsal @@ -17,7 +17,7 @@ </div> </div> <div > - <form enctype="multipart/form-data" method="post" class="gap-16 items-center py-8 px-4 mx-auto max-w-screen-xl lg:grid lg:grid-cols-2 lg:py-16 lg:px-6"> + <form enctype="multipart/form-data" method="post" class="gap-16 items-center py-8 px-4 mx-auto max-w-screen-xl lg:grid lg:grid-cols-2"> {% csrf_token %} <input class="block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400" @@ -31,6 +31,31 @@ </button> </form> </div> + + <audio id="myAudio"> + <source src="{% static 'src/media/G53-44104-1111-00083.wav' %}" type="audio/wav"> + Your browser does not support the audio element. + </audio> + + <div class="gap-16 items-center py-8 px-4 mx-auto max-w-screen-xl lg:grid lg:grid-cols-2 lg:py-8"> + <button onclick="playAudio()" type="button" class="text-white bg-gray-800 hover:bg-gray-900 focus:outline-none focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-gray-800 dark:hover:bg-gray-700 dark:focus:ring-gray-700 dark:border-gray-700"> + Play Audio</button> + <button onclick="pauseAudio()" type="button" class="text-white bg-gray-800 hover:bg-gray-900 focus:outline-none focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-gray-800 dark:hover:bg-gray-700 dark:focus:ring-gray-700 dark:border-gray-700"> + Pause Audio</button> + </div> + + <script> + var x = document.getElementById("myAudio"); + + function playAudio() { + x.play(); + } + + function pauseAudio() { + x.pause(); + } + </script> + </section> diff --git a/myproject/myapp/views.py b/myproject/myapp/views.py index 0854a991a226e8cba5e99449c2dc86a162413812..afaaf33c937d81d6e7bc13c01422144110526f48 100644 --- a/myproject/myapp/views.py +++ b/myproject/myapp/views.py @@ -2,21 +2,19 @@ from django.shortcuts import render from django.template import RequestContext def index(request): - - if request.method == 'POST': - if request.FILES['audio_file'] != None: - uploaded_file = request.FILES['audio_file'] - # Do something with the uploaded file - return render(request, 'index1.html') + #for now this authenication just returns the main view + #when user auth is done change the else to return index2.html + if request.user.is_authenticated: + if request.method == 'POST': + if request.FILES['audio_file'] != None: + uploaded_file = request.FILES['audio_file'] + # Do something with the uploaded file + return render(request, 'index1.html') + else: + return render(request, 'index1.html') else: return render(request, 'index1.html') - # if request.user.is_authenticated: - # return render(request, 'index1.html') - # else: - # return render(request, 'index1.html') - - - + def users(request): return render(request, 'user_page.html')