arham061 commited on
Commit
b80857a
1 Parent(s): 87c1174

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -7
app.py CHANGED
@@ -2,6 +2,8 @@ import torch
2
  from transformers import SpeechT5ForTextToSpeech, SpeechT5Processor
3
  import soundfile as sf
4
  import gradio as gr
 
 
5
 
6
  # Load the TTS model from the Hugging Face Hub
7
  checkpoint = "arham061/speecht5_finetuned_voxpopuli_nl" # Replace with your actual model name
@@ -12,12 +14,61 @@ tokenizer = processor.tokenizer
12
 
13
  # Buckwalter to Unicode mapping
14
  buck2uni = {
15
- u"\u0627": "A",
16
- u"\u0675": "A",
17
- u"\u0673": "A",
18
- u"\u0630": "A",
19
- u"\u0622": "AA",
20
- # Rest of the mapping...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
22
 
23
  def transString(string, reverse=0):
@@ -54,7 +105,7 @@ def text_to_speech(text):
54
  audio_output = generate_audio(text)
55
 
56
  # Save audio as a .wav file
57
- sf.write("output.wav", audio_output, samplerate=16000, format='wav', subtype='PCM_16', endian='LITTLE', channels=1, dtype='int16', write_id3v2=False, type='numpy')
58
 
59
  return "output.wav"
60
 
 
2
  from transformers import SpeechT5ForTextToSpeech, SpeechT5Processor
3
  import soundfile as sf
4
  import gradio as gr
5
+ import scipy.io.wavfile as wav
6
+ import numpy as np
7
 
8
  # Load the TTS model from the Hugging Face Hub
9
  checkpoint = "arham061/speecht5_finetuned_voxpopuli_nl" # Replace with your actual model name
 
14
 
15
  # Buckwalter to Unicode mapping
16
  buck2uni = {
17
+ u"\u0627":"A",
18
+ u"\u0627":"A",
19
+ u"\u0675":"A",
20
+ u"\u0673":"A",
21
+ u"\u0630":"A",
22
+ u"\u0622":"AA",
23
+ u"\u0628":"B",
24
+ u"\u067E":"P",
25
+ u"\u062A":"T",
26
+ u"\u0637":"T",
27
+ u"\u0679":"T",
28
+ u"\u062C":"J",
29
+ u"\u0633":"S",
30
+ u"\u062B":"S",
31
+ u"\u0635":"S",
32
+ u"\u0686":"CH",
33
+ u"\u062D":"H",
34
+ u"\u0647":"H",
35
+ u"\u0629":"H",
36
+ u"\u06DF":"H",
37
+ u"\u062E":"KH",
38
+ u"\u062F":"D",
39
+ u"\u0688":"D",
40
+ u"\u0630":"Z",
41
+ u"\u0632":"Z",
42
+ u"\u0636":"Z",
43
+ u"\u0638":"Z",
44
+ u"\u068E":"Z",
45
+ u"\u0631":"R",
46
+ u"\u0691":"R",
47
+ u"\u0634":"SH",
48
+ u"\u063A":"GH",
49
+ u"\u0641":"F",
50
+ u"\u06A9":"K",
51
+ u"\u0642":"K",
52
+ u"\u06AF":"G",
53
+ u"\u0644":"L",
54
+ u"\u0645":"M",
55
+ u"\u0646":"N",
56
+ u"\u06BA":"N",
57
+ u"\u0648":"O",
58
+ u"\u0649":"Y",
59
+ u"\u0626":"Y",
60
+ u"\u06CC":"Y",
61
+
62
+ u"\u06D2":"E",
63
+ u"\u06C1":"H",
64
+ u"\u064A":"E" ,
65
+ u"\u06C2":"AH" ,
66
+ u"\u06BE":"H" ,
67
+ u"\u0639":"A" ,
68
+ u"\u0643":"K" ,
69
+ u"\u0621":"A",
70
+ u"\u0624":"O",
71
+ u"\u060C":"" #seperator ulta comma
72
  }
73
 
74
  def transString(string, reverse=0):
 
105
  audio_output = generate_audio(text)
106
 
107
  # Save audio as a .wav file
108
+ wav.write("output.wav", 16000, audio_output.astype(np.int16))
109
 
110
  return "output.wav"
111