diff --git a/src/Providers/PicottsProvider.php b/src/Providers/PicottsProvider.php index 2aae9e0..1161361 100644 --- a/src/Providers/PicottsProvider.php +++ b/src/Providers/PicottsProvider.php @@ -12,6 +12,7 @@ use function explode; use function file_exists; use function file_get_contents; +use function md5; use function preg_match; use function strlen; use function strtolower; @@ -128,7 +129,7 @@ public function getOptions(): array */ public function textToSpeech(string $text, FactoryInterface $factory = null): string { - $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "speaker_picotts.wav"; + $filename = sys_get_temp_dir() . \DIRECTORY_SEPARATOR . "speaker_picotts_{$this->language}_" . md5($text) . ".wav"; if (file_exists($filename)) { unlink($filename); diff --git a/tests/Providers/PicottsProviderTest.php b/tests/Providers/PicottsProviderTest.php index 05b0c2f..a1ce885 100644 --- a/tests/Providers/PicottsProviderTest.php +++ b/tests/Providers/PicottsProviderTest.php @@ -140,7 +140,7 @@ public function testTextToSpeechError(): void $this->result->shouldReceive("getStatus")->once()->with()->andReturn(0); $this->expectException(ProviderException::class); - $this->expectExceptionMessage("TextToSpeech unable to create file: /tmp/speaker_picotts.wav"); + $this->expectExceptionMessageMatches("/^TextToSpeech unable to create file: \/tmp\/speaker_picotts_en-US_[a-f0-9]{32}\.wav$/"); $provider->textToSpeech("Hello", $this->factory); }