zee2221 commited on
Commit
03fc067
·
1 Parent(s): 4c3bb61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -5,7 +5,11 @@ from io import BytesIO
5
  from pydub import AudioSegment
6
 
7
  # Set up OpenAI API
8
- openai.api_key = "YOUR_API_KEY"
 
 
 
 
9
 
10
 
11
  def generate_presentation(topic):
@@ -29,19 +33,17 @@ def generate_presentation(topic):
29
 
30
  def generate_audio(text):
31
  # Set up text-to-speech API parameters
32
- api_key = "YOUR_API_KEY"
33
- api_url = "https://api.fpt.ai/hmi/tts/v5"
34
  voice = "banmai"
35
  speed = "0"
36
 
37
  # Send a request to the text-to-speech API
38
  headers = {
39
- "api-key": api_key,
40
  "voice": voice,
41
  "speed": speed
42
  }
43
  data = {"text": text}
44
- response = requests.post(api_url, headers=headers, json=data)
45
 
46
  # Convert the response audio to a playable format
47
  audio_bytes = BytesIO(response.content)
 
5
  from pydub import AudioSegment
6
 
7
  # Set up OpenAI API
8
+ openai.api_key = "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"
9
+
10
+ # Set up FPT API
11
+ tts_api_key = "IsZh7u8eHrjHgALqn0XS3M4vvouN331F"
12
+ tts_api_url = "https://api.fpt.ai/hmi/tts/v5"
13
 
14
 
15
  def generate_presentation(topic):
 
33
 
34
  def generate_audio(text):
35
  # Set up text-to-speech API parameters
 
 
36
  voice = "banmai"
37
  speed = "0"
38
 
39
  # Send a request to the text-to-speech API
40
  headers = {
41
+ "api-key": tts_api_key,
42
  "voice": voice,
43
  "speed": speed
44
  }
45
  data = {"text": text}
46
+ response = requests.post(tts_api_url, headers=headers, json=data)
47
 
48
  # Convert the response audio to a playable format
49
  audio_bytes = BytesIO(response.content)