File size: 1,523 Bytes
b996efe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c8a14d6
b996efe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import speech_recognition as sr
from pydub import AudioSegment
import soundfile
import pyrebase
from pydub import AudioSegment
import soundfile
import os
import pyrebase
import gradio as gr
from transformers import AutoProcessor
from transformers import  Wav2Vec2ForCTC
import gradio as gr
import torch
import torchaudio
from transformers import pipeline

classifier = pipeline("audio-classification", model="omarelsayeed/ed8am_elnoon_weltanween_bedon8onna")


def recite_wav(path_name):
  # fix pcm_16 error
    # data, samplerate = soundfile.read(path_name)
    # soundfile.write('_.wav', data , samplerate , subtype='PCM_16')
    return classifier(path_name)
  
      
def list_all_files():
   for _file in storage.child("wavfiles").list_files():
     print(_file.name)

def download_wav_file(wav_name):
   storage.child("wavfiles").child(wav_name).download("xd.wav")
   
def get_quran_text(wav_file_path):
    download_wav_file(wav_file_path)
    recitation = recite_wav("xd.wav")
    os.remove("xd.wav")
    return recitation   

firebaseConfig = {
  "apiKey": "AIzaSyDjgBD762KveE8GBO7jqTTkj_mKhUTDwGM",
  "authDomain": "quran-c5cbe.firebaseapp.com",
  "databaseURL":"quran-c5cbe.firebaseio.com/",
  "projectId": "quran-c5cbe",
  "storageBucket": "quran-c5cbe.appspot.com",
  "serviceAccount":"quran-c5cbe-firebase-adminsdk-jvpbe-cebaf5aaa6.json"
}

firebase = pyrebase.initialize_app(firebaseConfig)

storage = firebase.storage()

iface = gr.Interface(fn=get_quran_text, inputs="text", outputs="text")

iface.launch()