Spaces:
Runtime error
Runtime error
asd
Browse files- app.py +80 -0
- audio file converter/README.md +13 -0
- audio file converter/app.py +80 -0
- audio file converter/requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from turtle import onclick
|
3 |
+
import streamlit as st
|
4 |
+
from pydub import AudioSegment
|
5 |
+
import pydub
|
6 |
+
from pydub.playback import play
|
7 |
+
from scipy.io import wavfile
|
8 |
+
from os import path
|
9 |
+
import os
|
10 |
+
|
11 |
+
|
12 |
+
st.title("Audio Format Converter...")
|
13 |
+
upfile = st.file_uploader("Choose a Audio file",type=['.mp3', '.wav', '.ogg','.raw','.flac','.3gp','.3g'])
|
14 |
+
st.write(upfile)
|
15 |
+
from playsound import playsound
|
16 |
+
|
17 |
+
# @st.cache
|
18 |
+
def load_audio(audio):
|
19 |
+
au = st.audio(audio,format = 'audio/wav')
|
20 |
+
|
21 |
+
return au
|
22 |
+
|
23 |
+
def conv(audio,title,to):
|
24 |
+
st.title(audio)
|
25 |
+
sound = AudioSegment.from_mp3(audio)
|
26 |
+
export = "converted Audios/"+title+"."+to
|
27 |
+
st.title(export)
|
28 |
+
sound.export(export, format="wav")
|
29 |
+
st.success("Audio Successfuly Converted And saved in converted Audios folder")
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
if upfile is not None:
|
35 |
+
file_details = {"filename":upfile.name,"type":upfile.type}
|
36 |
+
# path = os.getcwd()
|
37 |
+
st.write(file_details)
|
38 |
+
st.write(upfile)
|
39 |
+
audio = load_audio(upfile)
|
40 |
+
with open(os.path.join("file uploaded",upfile.name),"wb") as f:
|
41 |
+
f.write(upfile.getbuffer())
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
|
49 |
+
try:
|
50 |
+
|
51 |
+
# from1 = st.selectbox(
|
52 |
+
# 'What is your current file format?',
|
53 |
+
# ('.mp3', '.wav', '.ogg','.raw','.flac','.3gp','.3g'))
|
54 |
+
title = st.text_input('Rename Audio', '')
|
55 |
+
# st.write('New Name For This Audio', title)
|
56 |
+
to = st.selectbox(
|
57 |
+
'In which format you want to convert?',
|
58 |
+
('mp3', 'wav', 'ogg','raw','flac','3gp','3g'))
|
59 |
+
|
60 |
+
file = "file uploaded/"+upfile.name
|
61 |
+
|
62 |
+
if st.button("Convert"):
|
63 |
+
conv(file,title,to)
|
64 |
+
|
65 |
+
|
66 |
+
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
except:
|
77 |
+
st.write("Please Upload your Audio File To continue")
|
78 |
+
|
79 |
+
|
80 |
+
|
audio file converter/README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Audio Converter
|
3 |
+
emoji: π
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: green
|
6 |
+
sdk: streamlit
|
7 |
+
sdk_version: 1.15.2
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: other
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
audio file converter/app.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from turtle import onclick
|
3 |
+
import streamlit as st
|
4 |
+
from pydub import AudioSegment
|
5 |
+
import pydub
|
6 |
+
from pydub.playback import play
|
7 |
+
from scipy.io import wavfile
|
8 |
+
from os import path
|
9 |
+
import os
|
10 |
+
|
11 |
+
|
12 |
+
st.title("Audio Format Converter...")
|
13 |
+
upfile = st.file_uploader("Choose a Audio file",type=['.mp3', '.wav', '.ogg','.raw','.flac','.3gp','.3g'])
|
14 |
+
st.write(upfile)
|
15 |
+
from playsound import playsound
|
16 |
+
|
17 |
+
# @st.cache
|
18 |
+
def load_audio(audio):
|
19 |
+
au = st.audio(audio,format = 'audio/wav')
|
20 |
+
|
21 |
+
return au
|
22 |
+
|
23 |
+
def conv(audio,title,to):
|
24 |
+
st.title(audio)
|
25 |
+
sound = AudioSegment.from_mp3(audio)
|
26 |
+
export = "converted Audios/"+title+"."+to
|
27 |
+
st.title(export)
|
28 |
+
sound.export(export, format="wav")
|
29 |
+
st.success("Audio Successfuly Converted And saved in converted Audios folder")
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
if upfile is not None:
|
35 |
+
file_details = {"filename":upfile.name,"type":upfile.type}
|
36 |
+
# path = os.getcwd()
|
37 |
+
st.write(file_details)
|
38 |
+
st.write(upfile)
|
39 |
+
audio = load_audio(upfile)
|
40 |
+
with open(os.path.join("file uploaded",upfile.name),"wb") as f:
|
41 |
+
f.write(upfile.getbuffer())
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
|
49 |
+
try:
|
50 |
+
|
51 |
+
# from1 = st.selectbox(
|
52 |
+
# 'What is your current file format?',
|
53 |
+
# ('.mp3', '.wav', '.ogg','.raw','.flac','.3gp','.3g'))
|
54 |
+
title = st.text_input('Rename Audio', '')
|
55 |
+
# st.write('New Name For This Audio', title)
|
56 |
+
to = st.selectbox(
|
57 |
+
'In which format you want to convert?',
|
58 |
+
('mp3', 'wav', 'ogg','raw','flac','3gp','3g'))
|
59 |
+
|
60 |
+
file = "file uploaded/"+upfile.name
|
61 |
+
|
62 |
+
if st.button("Convert"):
|
63 |
+
conv(file,title,to)
|
64 |
+
|
65 |
+
|
66 |
+
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
except:
|
77 |
+
st.write("Please Upload your Audio File To continue")
|
78 |
+
|
79 |
+
|
80 |
+
|
audio file converter/requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
pydub
|
2 |
+
playsound
|
3 |
+
turtle
|
4 |
+
scipy
|