cartesia-ai / cartesia-js

The JavaScript client for the Cartesia API.
MIT License
55 stars 10 forks source link

Can't use the React hook in Expo #18

Open jackguo709 opened 4 days ago

jackguo709 commented 4 days ago

expo/tsconfig.base uses modulResolution: "node". So when I try to import { useTTS } from "@cartesia/cartesia-js/react", it says the result could not be resolved. Any workarounds?

jackguo709 commented 4 days ago

I ended up using

import "partysocket/event-target-polyfill";
import { useTTS } from "@cartesia/cartesia-js/dist/react";

However, I don't hear any sound. I just copy-pasted from the sample code:

tts
      .buffer({
        model_id: "sonic-english",
        voice: {
          mode: "id",
          id: "a0e99841-438c-4a64-b679-ae501e7d6091",
        },
        transcript: "hello there",
      })
      .then(async () => {
        await tts.play();
      });