@broberg/ai-sdk 0.43.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -479,6 +479,11 @@ interface DialogueTurn {
479
479
  }
480
480
  interface DialogueRequest {
481
481
  inputs: DialogueTurn[];
482
+ /** F051.4 — the pronunciation dictionary, applied to EACH line. cms measured the
483
+ * gap: a two-host podcast could not get a dictionary at all, so "broberg.ai" was
484
+ * said wrong in every episode — they could fix the sponsor read and the host's
485
+ * hand-off (both `ai.tts`) and not the conversation, which is 95% of the audio. */
486
+ pronunciations?: Pronunciation[];
482
487
  /** Output container, e.g. "mp3" (default). */
483
488
  format?: string;
484
489
  spec: TierSpec;
@@ -1837,6 +1842,29 @@ declare const podcastInputSchema: z.ZodObject<{
1837
1842
  }>, "many">;
1838
1843
  voices: z.ZodRecord<z.ZodString, z.ZodString>;
1839
1844
  format: z.ZodOptional<z.ZodString>;
1845
+ /** F051.4 — same field, same semantics as tts. Applied PER LINE: ElevenLabs'
1846
+ * /text-to-dialogue takes inputs[].text separately, so there is no composed string
1847
+ * a replacement could run across a speaker boundary in. */
1848
+ pronunciations: z.ZodOptional<z.ZodArray<z.ZodObject<{
1849
+ word: z.ZodString;
1850
+ alias: z.ZodOptional<z.ZodString>;
1851
+ ipa: z.ZodOptional<z.ZodString>;
1852
+ lang: z.ZodOptional<z.ZodString>;
1853
+ /** F051.3 — also match inside a hyphenated compound ("AI" in "AI-agenter"). */
1854
+ matchInCompounds: z.ZodOptional<z.ZodBoolean>;
1855
+ }, "strip", z.ZodTypeAny, {
1856
+ word: string;
1857
+ matchInCompounds?: boolean | undefined;
1858
+ alias?: string | undefined;
1859
+ ipa?: string | undefined;
1860
+ lang?: string | undefined;
1861
+ }, {
1862
+ word: string;
1863
+ matchInCompounds?: boolean | undefined;
1864
+ alias?: string | undefined;
1865
+ ipa?: string | undefined;
1866
+ lang?: string | undefined;
1867
+ }>, "many">>;
1840
1868
  }, "strip", z.ZodTypeAny, {
1841
1869
  script: {
1842
1870
  text: string;
@@ -1857,6 +1885,13 @@ declare const podcastInputSchema: z.ZodObject<{
1857
1885
  })[] | undefined;
1858
1886
  labels?: Record<string, string> | undefined;
1859
1887
  format?: string | undefined;
1888
+ pronunciations?: {
1889
+ word: string;
1890
+ matchInCompounds?: boolean | undefined;
1891
+ alias?: string | undefined;
1892
+ ipa?: string | undefined;
1893
+ lang?: string | undefined;
1894
+ }[] | undefined;
1860
1895
  }, {
1861
1896
  script: {
1862
1897
  text: string;
@@ -1877,6 +1912,13 @@ declare const podcastInputSchema: z.ZodObject<{
1877
1912
  })[] | undefined;
1878
1913
  labels?: Record<string, string> | undefined;
1879
1914
  format?: string | undefined;
1915
+ pronunciations?: {
1916
+ word: string;
1917
+ matchInCompounds?: boolean | undefined;
1918
+ alias?: string | undefined;
1919
+ ipa?: string | undefined;
1920
+ lang?: string | undefined;
1921
+ }[] | undefined;
1880
1922
  }>;
1881
1923
  declare const ttsInputSchema: z.ZodObject<{
1882
1924
  tier: z.ZodOptional<z.ZodEnum<["fast", "smart", "powerful", "cheap", "vision", "video", "embedding"]>>;
@@ -1962,8 +2004,8 @@ declare const ttsInputSchema: z.ZodObject<{
1962
2004
  transport: "http" | "subprocess";
1963
2005
  })[] | undefined;
1964
2006
  labels?: Record<string, string> | undefined;
1965
- format?: string | undefined;
1966
2007
  lang?: string | undefined;
2008
+ format?: string | undefined;
1967
2009
  pronunciations?: {
1968
2010
  word: string;
1969
2011
  matchInCompounds?: boolean | undefined;
@@ -1989,8 +2031,8 @@ declare const ttsInputSchema: z.ZodObject<{
1989
2031
  transport: "http" | "subprocess";
1990
2032
  })[] | undefined;
1991
2033
  labels?: Record<string, string> | undefined;
1992
- format?: string | undefined;
1993
2034
  lang?: string | undefined;
2035
+ format?: string | undefined;
1994
2036
  pronunciations?: {
1995
2037
  word: string;
1996
2038
  matchInCompounds?: boolean | undefined;
@@ -2390,8 +2432,8 @@ declare const falStubAdapter: ProviderAdapter;
2390
2432
  * wires the live adapters. */
2391
2433
  declare const stubProviders: Record<string, ProviderAdapter>;
2392
2434
 
2393
- declare const VERSION: "0.43.0";
2394
- declare const SDK_TAG: "@broberg/ai-sdk@0.43.0";
2435
+ declare const VERSION: "0.44.0";
2436
+ declare const SDK_TAG: "@broberg/ai-sdk@0.44.0";
2395
2437
 
2396
2438
  /** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
2397
2439
  * per-call override.
package/dist/index.js CHANGED
@@ -1617,7 +1617,13 @@ function elevenlabsAdapter(config = {}) {
1617
1617
  headers: { "xi-api-key": key(), "content-type": "application/json", accept: "audio/mpeg" },
1618
1618
  body: JSON.stringify({
1619
1619
  model_id: req.spec.model,
1620
- inputs: req.inputs.map((t) => ({ text: t.text, voice_id: t.voiceId })),
1620
+ // F051.4 — PER LINE. The endpoint takes each turn's text separately, so the
1621
+ // dictionary applies exactly as it does in tts; composing the script into one
1622
+ // string first would let a replacement run across a speaker boundary.
1623
+ inputs: req.inputs.map((t) => ({
1624
+ text: ttsText({ text: t.text, pronunciations: req.pronunciations }),
1625
+ voice_id: t.voiceId
1626
+ })),
1621
1627
  ...req.format ? { output_format: req.format } : {}
1622
1628
  })
1623
1629
  });
@@ -3055,12 +3061,6 @@ var moderationInputSchema = z.object({
3055
3061
  input: z.union([z.string(), z.array(z.string())]),
3056
3062
  ...callOptions
3057
3063
  });
3058
- var podcastInputSchema = z.object({
3059
- script: z.array(z.object({ speaker: z.string(), text: z.string() })).min(1),
3060
- voices: z.record(z.string(), z.string()),
3061
- format: z.string().optional(),
3062
- ...callOptions
3063
- });
3064
3064
  var pronunciationSchema = z.object({
3065
3065
  word: z.string(),
3066
3066
  alias: z.string().optional(),
@@ -3069,6 +3069,16 @@ var pronunciationSchema = z.object({
3069
3069
  /** F051.3 — also match inside a hyphenated compound ("AI" in "AI-agenter"). */
3070
3070
  matchInCompounds: z.boolean().optional()
3071
3071
  });
3072
+ var podcastInputSchema = z.object({
3073
+ script: z.array(z.object({ speaker: z.string(), text: z.string() })).min(1),
3074
+ voices: z.record(z.string(), z.string()),
3075
+ format: z.string().optional(),
3076
+ /** F051.4 — same field, same semantics as tts. Applied PER LINE: ElevenLabs'
3077
+ * /text-to-dialogue takes inputs[].text separately, so there is no composed string
3078
+ * a replacement could run across a speaker boundary in. */
3079
+ pronunciations: z.array(pronunciationSchema).optional(),
3080
+ ...callOptions
3081
+ });
3072
3082
  var ttsInputSchema = z.object({
3073
3083
  text: z.string(),
3074
3084
  voice: z.string(),
@@ -3116,8 +3126,8 @@ var aiConfigSchema = z.object({
3116
3126
  });
3117
3127
 
3118
3128
  // src/version.ts
3119
- var VERSION = "0.43.0";
3120
- var SDK_TAG = "@broberg/ai-sdk@0.43.0";
3129
+ var VERSION = "0.44.0";
3130
+ var SDK_TAG = "@broberg/ai-sdk@0.44.0";
3121
3131
 
3122
3132
  // src/cost/sinks/upmetrics.ts
3123
3133
  function upmetricsSink(config) {
@@ -3646,7 +3656,7 @@ function createAI(config = {}) {
3646
3656
  invoke: async (spec) => {
3647
3657
  const adapter = pickProvider(spec.provider);
3648
3658
  if (!adapter.dialogue) throw new Error(`createAI: provider "${spec.provider}" does not support podcast/dialogue`);
3649
- return adapter.dialogue({ inputs, format: input.format, spec });
3659
+ return adapter.dialogue({ inputs, format: input.format, pronunciations: input.pronunciations, spec });
3650
3660
  }
3651
3661
  });
3652
3662
  },