gdnartea commited on
Commit
6719588
·
verified ·
1 Parent(s): 2b88fc3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -1,17 +1,21 @@
1
  import gradio as gr
2
- from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor, GPT2LMHeadModel, GPT2Tokenizer, VitsProcessor, VitsForConditionalGeneration
3
 
4
  # Load the ASR model and processor
5
- asr_processor = Wav2Vec2Processor.from_pretrained("/path/to/canary/processor")
6
- asr_model = Wav2Vec2ForCTC.from_pretrained("/path/to/canary/model")
7
 
8
  # Load the text processing model and tokenizer
9
- proc_tokenizer = GPT2Tokenizer.from_pretrained("/path/to/phi3/tokenizer")
10
- proc_model = GPT2LMHeadModel.from_pretrained("/path/to/phi3/model")
 
 
 
 
11
 
12
  # Load the TTS model and processor
13
- tts_processor = VitsProcessor.from_pretrained("facebook/vits-base")
14
- tts_model = VitsForConditionalGeneration.from_pretrained("facebook/vits-base")
15
 
16
  def process_speech(speech):
17
  # Convert the speech to text
 
1
  import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM, Speech2TextProcessor, Speech2TextForConditionalGeneration, VitsProcessor, VitsForConditionalGeneration
3
 
4
  # Load the ASR model and processor
5
+ asr_processor = Speech2TextProcessor.from_pretrained("/path/to/canary/processor")
6
+ asr_model = Speech2TextForConditionalGeneration.from_pretrained("/path/to/canary/model")
7
 
8
  # Load the text processing model and tokenizer
9
+ proc_tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-128k-instruct")
10
+ proc_model = AutoModelForCausalLM.from_pretrained(
11
+ "microsoft/Phi-3-mini-128k-instruct",
12
+ device_map="cuda",
13
+ torch_dtype="auto",
14
+ trust_remote_code=True,
15
 
16
  # Load the TTS model and processor
17
+ tts_processor = VitsProcessor.from_pretrained("/path/to/vits/processor")
18
+ tts_model = VitsForConditionalGeneration.from_pretrained("/path/to/vits/model")
19
 
20
  def process_speech(speech):
21
  # Convert the speech to text