SebastianSchramm commited on
Commit
1b42904
·
unverified ·
1 Parent(s): fa41d88

use one url const

Browse files
Files changed (1) hide show
  1. src/App.jsx +7 -2
src/App.jsx CHANGED
@@ -15,6 +15,8 @@ function App() {
15
  const [errorMessage, setErrorMessage] = useState(null);
16
  const audioRef = useRef(null);
17
 
 
 
18
  // Function to handle showing error messages and resetting the state
19
  const showError = (message) => {
20
  setErrorMessage(message);
@@ -39,7 +41,7 @@ function App() {
39
 
40
  try {
41
  const promptText = emotionPrompts[emotion][country.language] || emotionPrompts["anxiety"]["en"];
42
- const response = await fetch("https://sebastianschramm-tts.hf.space/genemotionfast/", {
43
  method: "POST",
44
  headers: {
45
  "Content-Type": "application/json",
@@ -72,6 +74,7 @@ function App() {
72
 
73
 
74
  const handleReadStory = async () => {
 
75
  // If any action is already in progress, prevent new actions immediately.
76
  if (currentAction !== 'idle') return;
77
 
@@ -85,8 +88,9 @@ function App() {
85
  }
86
 
87
  try {
 
88
  const promptText = storyPrompts[country.language] || storyPrompts["en"];
89
- const response = await fetch("https://sebastianschramm-tts.hf.space/genemotion/", {
90
  method: "POST",
91
  headers: {
92
  "Content-Type": "application/json",
@@ -96,6 +100,7 @@ function App() {
96
  language: country.language,
97
  }),
98
  });
 
99
 
100
  if (!response.ok) throw new Error("Failed to fetch audio");
101
 
 
15
  const [errorMessage, setErrorMessage] = useState(null);
16
  const audioRef = useRef(null);
17
 
18
+ const url = "https://sebastianschramm-ttsfast.hf.space/genemotionfast/";
19
+
20
  // Function to handle showing error messages and resetting the state
21
  const showError = (message) => {
22
  setErrorMessage(message);
 
41
 
42
  try {
43
  const promptText = emotionPrompts[emotion][country.language] || emotionPrompts["anxiety"]["en"];
44
+ const response = await fetch(url, {
45
  method: "POST",
46
  headers: {
47
  "Content-Type": "application/json",
 
74
 
75
 
76
  const handleReadStory = async () => {
77
+ console.log("handleReadStory called");
78
  // If any action is already in progress, prevent new actions immediately.
79
  if (currentAction !== 'idle') return;
80
 
 
88
  }
89
 
90
  try {
91
+ console.log("Fetching story prompt for language:", country.language);
92
  const promptText = storyPrompts[country.language] || storyPrompts["en"];
93
+ const response = await fetch(url, {
94
  method: "POST",
95
  headers: {
96
  "Content-Type": "application/json",
 
100
  language: country.language,
101
  }),
102
  });
103
+ console.log("Response status:", response.status);
104
 
105
  if (!response.ok) throw new Error("Failed to fetch audio");
106