Siddhant commited on
Commit
8ed40d7
1 Parent(s): 8b0046a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -1
app.py CHANGED
@@ -48,7 +48,21 @@ user_role = "user"
48
  tts_model = TTS(language="EN_NEWEST", device="auto")
49
  speaker_id = tts_model.hps.data.spk2id["EN-Newest"]
50
  blocksize = 512
 
 
 
 
 
 
51
  transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-tiny.en", device="cuda")
 
 
 
 
 
 
 
 
52
  def int2float(sound):
53
  """
54
  Taken from https://github.com/snakers4/silero-vad
@@ -78,7 +92,21 @@ LM_model = AutoModelForCausalLM.from_pretrained(
78
  LM_pipe = pipeline(
79
  "text-generation", model=LM_model, tokenizer=LM_tokenizer, device="cuda"
80
  )
81
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  vad_model, _ = torch.hub.load("snakers4/silero-vad:v4.0", "silero_vad")
83
  vad_iterator = VADIterator(
84
  vad_model,
 
48
  tts_model = TTS(language="EN_NEWEST", device="auto")
49
  speaker_id = tts_model.hps.data.spk2id["EN-Newest"]
50
  blocksize = 512
51
+ tts_model.tts_to_file("text", speaker_id, quiet=True)
52
+ dummy_input = torch.randn(
53
+ (1, 80, 3000),
54
+ dtype="float16",
55
+ device="cuda",
56
+ )
57
  transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-tiny.en", device="cuda")
58
+ start_event = torch.cuda.Event(enable_timing=True)
59
+ end_event = torch.cuda.Event(enable_timing=True)
60
+ torch.cuda.synchronize()
61
+ start_event.record()
62
+ transcriber({"sampling_rate": sr, "raw": dummy_input})["text"]
63
+ end_event.record()
64
+ torch.cuda.synchronize()
65
+
66
  def int2float(sound):
67
  """
68
  Taken from https://github.com/snakers4/silero-vad
 
92
  LM_pipe = pipeline(
93
  "text-generation", model=LM_model, tokenizer=LM_tokenizer, device="cuda"
94
  )
95
+ dummy_input_text = "Write me a poem about Machine Learning."
96
+ dummy_chat = [{"role": "user", "content": dummy_input_text}]
97
+ start_event = torch.cuda.Event(enable_timing=True)
98
+ end_event = torch.cuda.Event(enable_timing=True)
99
+ torch.cuda.synchronize()
100
+ start_event.record()
101
+ LM_pipe(
102
+ dummy_chat,
103
+ max_new_tokens=32,
104
+ min_new_tokens=0,
105
+ temperature=0.0,
106
+ do_sample=False,
107
+ )
108
+ end_event.record()
109
+ torch.cuda.synchronize()
110
  vad_model, _ = torch.hub.load("snakers4/silero-vad:v4.0", "silero_vad")
111
  vad_iterator = VADIterator(
112
  vad_model,