zinoubm commited on
Commit
e2409e8
·
1 Parent(s): e6c597c

adding the docs

Browse files
__pycache__/constants.cpython-310.pyc CHANGED
Binary files a/__pycache__/constants.cpython-310.pyc and b/__pycache__/constants.cpython-310.pyc differ
 
app.py CHANGED
@@ -1,11 +1,35 @@
1
  import gradio as gr
2
- import librosa
3
  import openai
4
  from constants import *
5
 
6
 
7
  openai.api_key = OPENAI_API_KEY
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  def get_command(command, model, id2label):
11
  """
@@ -33,16 +57,6 @@ def transcribe(audio, text):
33
  audio_file = open(audio, "rb")
34
  transcription = openai.Audio.transcribe("whisper-1", audio_file, language="en")
35
  transcription = transcription["text"]
36
- # Downsample original frequency to 16000hrz
37
- # input, rate = librosa.load(audio, sr=16000)
38
-
39
- # getting text transcription
40
- # inputs = processor(input, sampling_rate=rate, return_tensors="pt")
41
- # generated_ids = model.generate(
42
- # inputs["input_features"], attention_mask=inputs["attention_mask"]
43
- # )
44
-
45
- # transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)
46
 
47
  result = get_command(transcription, MODEL, id2label)
48
  audio_res = resoponses.get(result)()
@@ -65,4 +79,7 @@ if __name__ == "__main__":
65
  gr.Audio(label="Machine Response (Audio Version)"),
66
  ],
67
  allow_flagging="auto",
 
 
 
68
  ).launch()
 
1
  import gradio as gr
 
2
  import openai
3
  from constants import *
4
 
5
 
6
  openai.api_key = OPENAI_API_KEY
7
 
8
+ title = "Car Seats Voice Commands"
9
+
10
+ description = """
11
+ This is a demo for controlling car seats with Voice Commands, On the left there's the inputs section
12
+ and on the right you'll find your outputs. For the inputs you have two choices **Voice** and **Text**,
13
+ Use **Voice** If you want a closer experience to the final product, Or use **Text** if you just want to test the command model.
14
+ for the outputs you have the **transcription**(Please check that it's accurate), **command**(to know which
15
+ command the system detected) and you have the robot voice (again use this if you want a more real experience).
16
+
17
+ **Features** : You can either activate of deactivate the following features
18
+ - Heated Seats
19
+ - Cooled Seats
20
+ - Massage Seats
21
+
22
+ Examples:
23
+ - **Direct Commands** : Try to say something like "Activate heated seats" or "Turn Off massage seats"
24
+ - **Indirect Commands** : Try "My back is cold" , "No heating is needed anymore" or "I'm stressed today"
25
+ """
26
+
27
+ article = """
28
+ This demo processes commands in two steps, the first step is the transcription phase and the second is the
29
+ Command Classification phase. For Transcription I used The OpenAi whisper model, and for the classification
30
+ I Fine-Tuned the OpenAi **ada** model on Car Seats Command.
31
+ """
32
+
33
 
34
  def get_command(command, model, id2label):
35
  """
 
57
  audio_file = open(audio, "rb")
58
  transcription = openai.Audio.transcribe("whisper-1", audio_file, language="en")
59
  transcription = transcription["text"]
 
 
 
 
 
 
 
 
 
 
60
 
61
  result = get_command(transcription, MODEL, id2label)
62
  audio_res = resoponses.get(result)()
 
79
  gr.Audio(label="Machine Response (Audio Version)"),
80
  ],
81
  allow_flagging="auto",
82
+ title=title,
83
+ description=description,
84
+ article=article,
85
  ).launch()
constants.py CHANGED
@@ -1,6 +1,5 @@
1
  from commands import ResponseManager
2
  from dotenv import load_dotenv
3
- from transformers import Speech2TextProcessor, Speech2TextForConditionalGeneration
4
  import os
5
 
6
  load_dotenv()
@@ -36,9 +35,3 @@ text_respnses = {
36
  "cooled_seats_on": "Cooled seats activated",
37
  "cooled_seats_off": "Cooled seats deactivated",
38
  }
39
-
40
- # model = Speech2TextForConditionalGeneration.from_pretrained(
41
- # "facebook/s2t-small-librispeech-asr"
42
- # )
43
-
44
- # processor = Speech2TextProcessor.from_pretrained("facebook/s2t-small-librispeech-asr")
 
1
  from commands import ResponseManager
2
  from dotenv import load_dotenv
 
3
  import os
4
 
5
  load_dotenv()
 
35
  "cooled_seats_on": "Cooled seats activated",
36
  "cooled_seats_off": "Cooled seats deactivated",
37
  }
 
 
 
 
 
 
flagged/log.csv CHANGED
@@ -31,3 +31,8 @@ C:\Users\admin\Desktop\DS JRP\Programming\Python\Portfolio\Voice_Commands\flagge
31
  /home/boumaza/Desktop/Programming/Python/Voice_Commands/flagged/component 0/tmp68h39ev5.wav,,,,2023-03-03 11:54:26.488504
32
  ,I'm cold,,,2023-03-04 10:42:40.559129
33
  ,I'm cold,,,2023-03-04 10:44:49.418487
 
 
 
 
 
 
31
  /home/boumaza/Desktop/Programming/Python/Voice_Commands/flagged/component 0/tmp68h39ev5.wav,,,,2023-03-03 11:54:26.488504
32
  ,I'm cold,,,2023-03-04 10:42:40.559129
33
  ,I'm cold,,,2023-03-04 10:44:49.418487
34
+ /home/boumaza/Desktop/Programming/Python/Voice_Commands/flagged/component 0/tmpz0hq94rg.wav,,,,2023-03-04 11:32:53.276143
35
+ /home/boumaza/Desktop/Programming/Python/Voice_Commands/flagged/component 0/tmpr_cd3uqa.wav,,,,2023-03-04 11:33:22.605201
36
+ /home/boumaza/Desktop/Programming/Python/Voice_Commands/flagged/component 0/tmp8pxcjozd.wav,,,,2023-03-04 11:34:02.384882
37
+ /home/boumaza/Desktop/Programming/Python/Voice_Commands/flagged/component 0/tmp7vog58pt.wav,,,,2023-03-04 11:34:32.302966
38
+ /home/boumaza/Desktop/Programming/Python/Voice_Commands/flagged/component 0/tmp5v5ipo64.wav,,,,2023-03-04 11:34:50.524003